﻿namespace = mpo_nomad_events

############################
## Nomadic flavor events
## 0001-0099
## By Jason Cantalini
############################

mpo_nomad_events.1001 = {
	hidden = yes
	immediate = {
		var:beheaded_warrior = {
			save_scope_as = beheaded_warrior
		}
		var:beheaded_warrior_foe = {
			save_scope_as = beheaded_warrior_foe
		}
		var:beheaded_warrior_location = {
			save_scope_as = beheaded_warrior_location
		}
		if = {
			limit = {
				has_variable = beheaded_warrior_accolade
				exists = var:beheaded_warrior_accolade
			}
			var:beheaded_warrior_accolade = {
				save_scope_as = beheaded_warrior_accolade
			}
		}
		#ROOT might be in army camp and knight would be more appropriate
		random_courtier = {
			limit = {
				is_adult = yes
				can_be_combatant_based_on_gender_trigger = { ARMY_OWNER = root }
				OR = {
					is_available = yes
					AND = {
						is_in_army = yes
						root = {
							is_in_army = yes
						}
					}
				}
			}
			save_scope_as = head_bearer
		}
		if = {
			limit =	{
				NOT = {
					exists = scope:head_bearer
				}
			}
			random_vassal = {
			 	limit = {
					is_adult = yes
					can_be_combatant_based_on_gender_trigger = { ARMY_OWNER = root }
					OR = {
						is_available = yes
						AND = {
							is_in_army = yes
							root = {
								is_in_army = yes
							}
						}
					}
			 	}
			 	save_scope_as = head_bearer
			}
		}
		if = {
			limit =	{
				NOT = {
					exists = scope:head_bearer
				}
			}
			random_courtier = {
				limit = {
					is_adult = yes
					OR = {
						is_available = yes
						AND = {
							is_in_army = yes
							root = {
								is_in_army = yes
							}
						}
					}
				}
				save_scope_as = head_bearer
			}
		}
		if = {
			limit =	{
				NOT = {
					exists = scope:head_bearer
				}
			}
			random_pool_guest = {
			 	limit = {
					is_adult = yes
					is_available = yes
			 	}
			 	save_scope_as = head_bearer
			}
		}
		if = {
			limit =	{
				NOT = {
					exists = scope:head_bearer
				}
				exists = root.capital_province
			}
			random_pool_character = {
				province = root.capital_province
			 	limit = {
					is_adult = yes
					is_available = yes
			 	}
			 	save_scope_as = head_bearer
			}
		}
		#Save family member to send the head to
		if = {
			limit = {
				scope:beheaded_warrior = {
					exists = house
				}
			}
			scope:beheaded_warrior = {
				ordered_parent = {
					order_by = max_military_strength
					limit = {
						is_ai = yes
						is_ruler = yes
			 			highest_held_title_tier >= tier_county
			 			NOT = {
			 				this = root
			 			}
					}
					save_scope_as = beheaded_relative
				}
				if = {	
					limit = {
						NOT = {
							exists = scope:beheaded_relative
						}
					}
					ordered_child = {
						order_by = max_military_strength
						limit = {
							is_ai = yes
							is_ruler = yes
			 				highest_held_title_tier >= tier_county
			 				NOT = {
			 					this = root
			 				}
						}
						save_scope_as = beheaded_relative
					}
				}
				if = {	
					limit = {
						NOT = {
							exists = scope:beheaded_relative
						}
					}
					ordered_sibling = {
						order_by = max_military_strength
						limit = {
							is_ai = yes
							is_ruler = yes
			 				highest_held_title_tier >= tier_county
			 				NOR = {
			 					this = root
			 					scope:beheaded_warrior = {
			 						is_close_family_of = root
			 					}
			 				}
						}
						save_scope_as = beheaded_relative
					}
				}
				if = {	
					limit = {
						NOT = {
							exists = scope:beheaded_relative
						}
						exists = scope:beheaded_warrior.house.house_head
						scope:beheaded_warrior.house.house_head = {
							NOR = {
								this = scope:beheaded_warrior
								this = root
							}
						}
					}
					house = {
						house_head = {
							save_scope_as = beheaded_relative
						}
					}
				}
			}
		}
		#Create an artifact based on rank of dead person
		mpo_beheaded_warrior_artifact_creation_effect = yes
		trigger_event = mpo_nomad_events.1000
	}
}

#One of your dead baghaturs' heads is recovered
mpo_nomad_events.1000 = {
	type = character_event
	theme = battle
	title = mpo_nomad_events.1000.t
	desc = {
		#Triggered desc based on whether you're in an army
		first_valid = {
			triggered_desc = {
				trigger = {
					is_in_army = yes
				}
				desc = mpo_nomad_events.1000.army_camp
			}
			desc = mpo_nomad_events.1000.capital
		}
		#Triggered desc based on relation
		first_valid = {
			triggered_desc = {
				trigger = {
					scope:beheaded_warrior = {
						is_close_family_of = root
					}
				}
				desc = mpo_nomad_events.1000.family
			}
			triggered_desc = {
				trigger = {
					has_variable = beheaded_warrior_powerful_vassal
				}
				desc = mpo_nomad_events.1000.vassal
			}
			triggered_desc = {
				trigger = {
					has_variable = beheaded_warrior_councillor
				}
				desc = mpo_nomad_events.1000.councillor
			}
			desc = mpo_nomad_events.1000.generic_knight
		}
		desc = mpo_nomad_events.1000.desc
	}
	override_background = {
		trigger = {
			is_in_army = no
		}
		reference = courtyard
	}
	
	left_portrait = {
		character = root
		triggered_animation = {
			trigger = {
				scope:beheaded_warrior = {
					OR = {
						is_consort_of = root
						is_close_family_of = root
					}
				}
			}
			animation = grief
		}
		triggered_animation = {
			trigger = {
				scope:beheaded_warrior = {
					NOR = {
						is_consort_of = root
						is_close_family_of = root
					}
				}
			}
			animation = sadness
		}
	}
	right_portrait = {
		character = scope:head_bearer
		animation = standing_horse
		camera = camera_event_standing_with_horse_right
	}
	artifact = {
		target = scope:head_artifact
		position = lower_center_portrait
	}
	immediate = {
		if = {
			limit = {
				exists = scope:beheaded_warrior.house
			}
			scope:beheaded_warrior = {
				house = {
					add_house_artifact_claim = scope:head_artifact
				}
			}
		}
	}
	#Keep the head
	option = {
		name = mpo_nomad_events.1000.a
		flavor = mpo_nomad_events.1000.a.flavor
		
		custom_tooltip = keep_warrior_head_tt

		stress_impact = {
			cynical = minor_stress_impact_gain
		}
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_rationality = -0.5
			}
		}
	}
	#Send it to its people
	option = {
		trigger = {
		 	exists = scope:beheaded_relative
		}
		name = mpo_nomad_events.1000.b
		scope:beheaded_relative = {
			#Gains the artifact
			scope:head_artifact = {
				set_owner = {
					target = scope:beheaded_relative
					history = {
						location = root.capital_province
						actor = root
						recipient = scope:beheaded_relative
						type = given
					}
				}
			}
		}
		if = {
			limit = {
				can_add_hook = {
					target = scope:beheaded_relative
					type = favor_hook
				}
			}
			add_hook = {
				type = favor_hook
				target = scope:beheaded_relative
			}
		}
		
		scope:beheaded_warrior = {
			every_close_family_member = {
				custom = custom.every_beheaded_family
				limit = {
					NOR = {
						this = root
						this = scope:beheaded_relative
					}
				}
				add_opinion = {
					target = root
					modifier = respect_opinion
					opinion = 20
				}
			}
		}
		stress_impact = {
			greedy = medium_stress_impact_gain
			sadistic = minor_stress_impact_gain
		}
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_compassion = 0.5
				ai_greed = -0.5
			}
			modifier = {
				factor = 0
				has_trait = greedy
			}
		}
	}
	#The glory of the accolade grows
	option = {
		name = mpo_nomad_events.1000.c
		trigger = {
			has_variable = beheaded_warrior_accolade
		}
		#Accolade gains glory if it is active
		if = {
			limit = {
				var:beheaded_warrior_accolade = {
					is_accolade_active = yes
					exists = acclaimed_knight
				}
			}
			var:beheaded_warrior_accolade = {
				add_glory = medium_glory_gain
				acclaimed_knight = {
					save_scope_as = beheaded_accolade_knight
					#Give artifact to accolade knight
					scope:head_artifact = {
						set_owner = {
							target = scope:book_recipient
							history = {
								location = root.capital_province
								actor = root
								recipient = scope:beheaded_accolade_knight
								type = given
							}
						}
					}
					#gain opinion with accolade knight
					add_opinion = {
						target = root
						modifier = respect_opinion
						opinion = 25
					}
				}
			}
		}
		#Accolade successors appear if it isn't active
		else = {
			save_scope_as = accolade_owner
			scope:beheaded_warrior = {
				save_scope_as = knight_in_need
			}
			var:beheaded_warrior_accolade = {
				save_scope_as = accolade_in_need
			}
			every_knight = {
				custom = custom.every_knight
				add_opinion = {
					target = root
					modifier = respect_opinion
					opinion = 10
				}
			}
			custom_tooltip = beheaded_accolade_successor_tt
			trigger_event = {
				id = accolade.0006
			}
			destroy_artifact = scope:head_artifact
		}
		stress_impact = {
			content = minor_stress_impact_gain
			forgiving = minor_stress_impact_gain
		}
		ai_chance = {
			base = 200
			ai_value_modifier = {
				ai_vengefulness = 1
			}
			modifier = {
				factor = 0
				has_trait = eccentric
			}
		}
	}
	#Bury this head with honors
	option = {
		name = mpo_nomad_events.1000.d
		
		if = {
			limit = {
				mpo_important_beheaded_warrior_trigger = yes
			}
			capital_county = {
				add_county_modifier = {
					modifier = mpo_noble_warriors_grave_modifier
					years = 10
				}
			}
		}
		else = {
			capital_county = {
				add_county_modifier = {
					modifier = mpo_warriors_grave_modifier
					years = 10
				}
			}
		}
		add_piety = minor_piety_gain
		
		destroy_artifact = scope:head_artifact
		stress_impact = {
			eccentric = medium_stress_impact_gain
			vengeful = minor_stress_impact_gain
			greedy = minor_stress_impact_gain
		}
		ai_chance = {
			base = 200
			ai_value_modifier = {
				ai_vengefulness = -0.5
				ai_rationality = 0.5
			}
			modifier = {
				factor = 0
				has_trait = eccentric
			}
		}
	}
	after = {
		remove_variable = beheaded_warrior
		remove_variable = beheaded_warrior_foe
		remove_variable = beheaded_warrior_councillor
		remove_variable = beheaded_warrior_powerful_vassal
		remove_variable = beheaded_warrior_accolade
		remove_variable = beheaded_warrior_location
	}
}

#Hidden ruler's head artifact creation event
mpo_nomad_events.1010 = {
	hidden = yes
	immediate = {
		#Create head artifact
		if = {
			limit = {
				OR = {
					has_character_flag = execution_head_illustrious_flag
					has_character_flag = execution_head_famed_flag
				}
			}
			mpo_execution_head_artifact_creation_effect = yes
		}
		trigger_event = mpo_nomad_events.1011
	}
}

scripted_effect remove_execution_head_flags_effect = {
	scope:executioner = {
		remove_character_flag = execution_head_famed_flag
		remove_character_flag = execution_head_illustrious_flag
		remove_character_flag = execution_head_warscore_flag
		remove_character_flag = execution_head_vassalization_flag
		remove_character_flag = execution_head_prestige_flag
		remove_character_flag = execution_head_obedience_flag
		remove_character_flag = execution_head_hook_flag
	}
}

scripted_effect mpo_nomad_events_1011_heir_resents_effect = {
	if = {
		limit = {
			tier_difference = {
				target = scope:executioner
				value <= 1
			}
			tier_difference = {
				target = scope:executioner
				value >= -1
			}
			house.house_head = {
				this = scope:headless_heir
			}
			NOT = {
				scope:executioner = {
					exists = house
					house = scope:headless_heir.house
				}
			}
			scope:executioner = {
				exists = house
				house.house_head = {
					this = scope:executioner
				}
			}
			house_head_can_start_feud_against_trigger = { TARGET = scope:executioner }
		}
		house_feud_start_effect = {
			# Feuding House Head
			ACTOR = scope:headless_heir
			# Target House Head
			TARGET = scope:executioner
			# Feud Reason
			REASON = head_killed
			# House Member attacker if relevant 
			ATTACKER = scope:executioner
			# House Member victim if relevant
			VICTIM = scope:victim
		}
	}
	else = {
		if = {
			limit = {
				NOT = {
					has_relation_rival = scope:executioner
				}
			}
			set_relation_rival = {
				target = scope:executioner
				reason = rival_sent_predecessors_head
			}
		}
		else = {
			progress_towards_rival_effect = {
				REASON = rival_sent_predecessors_head
				CHARACTER = scope:executioner
				OPINION = default_rival_opinion
			}
		}
		if = {
			limit = {
				NAND = {
					scope:headless_heir = {
						has_variable = severed_head_cb_revenge
						var:severed_head_cb_revenge = {
							this = scope:executioner
						}
					}
				}
			}
			scope:headless_heir = {
				custom_tooltip = severed_head_cb_revenge_tt
				set_variable = {
					name = severed_head_cb_revenge
					value = scope:headless_heir
				}
			}
		}
	}
}
scripted_effect mpo_nomad_events_1011_heir_cowed_effect = {
	if = {
		limit = {
			has_character_flag = execution_head_warscore_flag
		}
		custom_tooltip = peace_acceptance_head_scare_tt
		set_variable = {
			name = peace_acceptance_head_scare
			value = scope:headless_heir
			years = 20
		}
	}
	else_if = {
		limit = {
			has_character_flag = execution_head_vassalization_flag
		}
		custom_tooltip = severed_head_vassalization_tt
		set_variable = {
			name = severed_head_vassalization
			value = scope:headless_heir
			years = 20
		}
	}
	else_if = {
		limit = {
			has_character_flag = execution_head_prestige_flag
		}
		#Lots of prestige for much higher tier
		if = {
			limit = {
				tier_difference = {
					target = scope:headless_heir
					value <= -3
				}
			}
			add_prestige = monumental_prestige_gain
		}
		else_if = {
			limit = {
				tier_difference = {
					target = scope:headless_heir
					value <= -2
				}
			}
			add_prestige = massive_prestige_gain
		}
		#Good prestige for higher tier
		else_if = {
			limit = {
				tier_difference = {
					target = scope:headless_heir
					value <= -1
				}
			}
			add_prestige = major_prestige_gain
		}
		#Some prestige
		else = {
			add_prestige = medium_prestige_gain
		}
	}
	else_if = {
		limit = {
			has_character_flag = execution_head_obedience_flag
			scope:headless_heir = { obedience_target = root }
		}
		scope:headless_heir = {
			add_opinion = {
				modifier = obedience_opinion
				target = root
			}
		}
	}
	else = {
		add_hook = {
			type = threat_hook
			target = scope:headless_heir
		}
	}
}

scripted_trigger mpo_nomad_events_1011_heir_unafraid_trigger = {
	scope:headless_heir.top_liege = {
		current_military_strength > scope:executioner.current_military_strength
		tier_difference = {
			target = scope:executioner
			value >= -1
		}
	}
	scope:headless_heir = {
		NOT = {
			has_dread_level_towards = {
				target = scope:executioner
				level >= 1
			}
		}
	}
}

#You have taken the head of a ruler prisoner
mpo_nomad_events.1011 = {
	type = character_event
	theme = death
	title = mpo_nomad_events.1011.t
	desc = {
		random_valid = {
			triggered_desc = {
				trigger = {
					scope:victim = {
						OR = {
							has_trait = brave
							has_trait = arrogant
							has_trait = vengeful
							has_trait = wrathful
							has_trait = sadistic
							has_trait = cynical
						}
						NOR = {
							has_trait = craven
							has_trait = paranoid
							has_trait = forgiving
						}
					}
				}
				desc = mpo_nomad_events.1011.desc_execution_spite
			}
			triggered_desc = {
				trigger = {
					scope:victim = {
						OR = {
							has_trait = ambitious
							has_trait = craven
							has_trait = paranoid
							has_trait = deceitful
							has_trait = greedy
							has_trait = fickle
							has_trait = arbitrary
						}
						NOR = {
							has_trait = content
							has_trait = calm
							has_trait = humble
							has_trait = zealous
						}
					}
				}
				desc = mpo_nomad_events.1011.desc_execution_beg
			}
			triggered_desc = {
				trigger = {
					scope:victim = {
						NOT = {
							has_trait = cynical
						}
					}
				}
				desc = mpo_nomad_events.1011.desc_execution_pray
			}
			triggered_desc = {
				trigger = {
					OR = {
						AND = {
							exists = scope:court_executioner
							scope:court_executioner = {
								prowess < decent_skill_rating
							}
						}
						scope:victim = {
							has_trait = cynical
						}
					}	
				}
				desc = mpo_nomad_events.1011.desc_bad_execution
			}
		}
		desc = mpo_nomad_events.1011.desc
		first_valid = {
			triggered_desc = {
				trigger = {
					exists = scope:headless_heir
				}
				desc = mpo_nomad_events.1011.desc_send_head
			}
			desc = mpo_nomad_events.1011.desc_cant_send
		}
		triggered_desc = {
			trigger = {
				exists = scope:head_artifact
			}
			desc = mpo_nomad_events.1011.desc_keep_head
		}
	}
	override_background = {
		trigger = {
			NOR = {
				is_in_army = yes
				is_travelling = yes
			}
		}
		reference = dungeon
	}
	override_background = {
		trigger = {
			OR = {
				is_in_army = yes
				is_travelling = yes
			}
		}
		reference = army_camp
	}
	left_portrait = {
		character = root
		animation = personality_vengeful
	}
	right_portrait = {
		character = scope:court_executioner
		animation = celebrate_sword
		camera = camera_event_right_forward
		hide_info = yes
	}
	artifact = {
		target = scope:head_artifact
		position = lower_left_portrait
	}
	lower_center_portrait = scope:victim
	lower_right_portrait = scope:headless_heir
	immediate = {
		if = {
			limit = {
				exists = court_position:executioner_court_position
				court_position:executioner_court_position = {
					is_available_allow_travelling = yes
				}
			}
			court_position:executioner_court_position = {
				save_scope_as = court_executioner
			}
		}
		else_if = {
			limit = {
				any_knight = {
					OR = {
						is_available_allow_travelling = yes
						AND = {
							is_in_army = yes
							root = {
								is_in_army = yes
							}
						}
					}
					is_ruler = no
				}
			}
			ordered_knight = {
				order_by = prowess
				limit = {
					OR = {
						is_available_allow_travelling = yes
						AND = {
							is_in_army = yes
							root = {
								is_in_army = yes
							}
						}
					}
					is_ruler = no
				}
				save_scope_as = court_executioner
			}
		}
		else_if = {
			limit = {
				any_courtier = {
					NOT = {
						is_close_family_of = root
					}
					is_adult = yes
					can_be_combatant_based_on_gender_trigger = { ARMY_OWNER = root }
					is_available_allow_travelling = yes
				}
			}
			ordered_courtier = {
				order_by = prowess
				limit = {
					NOT = {
						is_close_family_of = root
					}
					is_adult = yes
					can_be_combatant_based_on_gender_trigger = { ARMY_OWNER = root }
					is_available_allow_travelling = yes
				}
				save_scope_as = court_executioner
			}
		}
		#Setting up house feud that might happen
		if = {
			limit = {
				exists = scope:headless_heir
				tier_difference = {
					target = scope:executioner
					value <= 1
				}
				house.house_head = {
					this = scope:headless_heir
				}
				NOT = {
					scope:executioner = {
						exists = house
						house = scope:headless_heir.house
						house.house_head = {
							this = scope:executioner
						}
					}
				}
				house_head_can_start_feud_against_trigger = { TARGET = scope:executioner }
			}
			scope:headless_heir = {
				save_targeting_house_feud_story_effect = {
					RIVAL = scope:executioner
					SELF = scope:headless_heir
				}
			}
		}
	}
	#Keep the head
	option = {
		trigger = {
			exists = scope:head_artifact
		}
		name = mpo_nomad_events.1011.a
		flavor = mpo_nomad_events.1011.a.flavor
		custom_tooltip = keep_warrior_head_tt
		#NOTIFY HEIR THAT HEAD ARTIFACT WAS CREATED AND THEY HAVE CLAIM
		if = {
			limit = {
				exists = scope:victim.house
				exists = scope:headless_heir.house
				scope:victim.house = {
					this = scope:headless_heir.house
				}
			}
			scope:headless_heir = {
				house = {
					add_house_artifact_claim = scope:head_artifact
				}				
			}
		}
		remove_execution_head_flags_effect = yes
		ai_chance = {
			base = 500
			ai_value_modifier = {
				ai_zeal = 0.5
				ai_honor = 0.5
			}
			modifier = {
				has_character_flag = execution_head_illustrious_flag
				add = 500
			}
			modifier = {
				all_inventory_artifact_slots = full
				add = -800
			}
		}
	}

	#Send the head - but it might cause rivalry
	option = {
		trigger = {
			exists = scope:headless_heir
		}
		name = mpo_nomad_events.1011.b
		flavor = mpo_nomad_events.1011.b.flavor
		
		add_dread = miniscule_dread_gain
		#Random chance calculation used for AI (they get no event)
		if = {
			limit = {
				scope:headless_heir = {
					is_ai = yes
				}
			}
			random_list = {
				#they are cowed
				50 = {
					desc = mpo_nomad_events.1011.b.success
					modifier = {
						is_gurkhan = yes
						add = 20
					}
					modifier = {
						scope:headless_heir = {
							tier_difference = {
								target = root
								value <= -1
							}
						}
						add = 20
					}
					modifier = {
						scope:headless_heir = {
							tier_difference = {
								target = root
								value <= -2
							}
						}
						add = 20
					}
					modifier = {
						scope:headless_heir = {
							tier_difference = {
								target = root
								value <= -3
							}
						}
						add = 20
					}
					modifier = {
						scope:headless_heir.top_liege = {
							tier_difference = {
								target = root.top_liege
								value <= -1
							}
						}
						add = 20
					}
					modifier = {
						scope:headless_heir.top_liege = {
							tier_difference = {
								target = root.top_liege
								value <= -2
							}
						}
						add = 20
					}
					modifier = {
						scope:headless_heir.top_liege = {
							tier_difference = {
								target = root.top_liege
								value <= -3
							}
						}
						add = 20
					}
					modifier = {
						scope:headless_heir = {
							current_military_strength < root.current_military_strength
						}
						add = 30
					}
					modifier = {
						scope:headless_heir = {
							max_military_strength < root.max_military_strength
						}
						add = 30
					}
					modifier = {
						scope:headless_heir.top_liege = {
							current_military_strength < root.top_liege.current_military_strength
						}
						add = 30
					}
					modifier = {
						scope:headless_heir.top_liege = {
							max_military_strength < root.top_liege.max_military_strength
						}
						add = 30
					}
					#Has unrelated wars to deal with
					modifier = {
						scope:headless_heir = {
							any_character_war = {
								NOT = {
									any_war_participant = {
										this = root
									}
								}
							}
						}
						add = 20
					}
					#Root holds family hostage
					modifier = {
						scope:headless_heir = {
							any_close_family_member = {
								is_imprisoned_by = root
							}
						}
						add = 15
					}
					modifier = {
						scope:headless_heir = {
							exists = player_heir
							player_heir = {
								is_imprisoned_by = root
							}
						}
						add = 30
					}
					modifier = {
						scope:headless_heir = {
							age <= 12
						}
						add = 25
					}
					modifier = {
						scope:headless_heir = {
							legitimacy_level <= 0
						}
						add = 20
					}
					modifier = {
						has_trait = conqueror
						add = 40
					}
					modifier = {
						has_trait = greatest_of_khans
						add = 40
					}
					modifier = {
						scope:headless_heir = {
							gold < 0
						}
						add = 15
					}
					modifier = {
						scope:headless_heir = {
							has_dread_level_towards = {
								target = scope:executioner
								level >= 1
							}
						}
						factor = 5
					}
					modifier = {
						scope:headless_heir = {
							has_dread_level_towards = {
								target = scope:executioner
								level >= 2
							}
						}
						factor = 10
					}
					modifier = {
						scope:headless_heir = {
							ai_vengefulness <= low_negative_ai_value
						}
						add = 40
					}
					modifier = {
						scope:headless_heir = {
							ai_vengefulness <= high_negative_ai_value
						}
						add = 80
					}
					modifier = {
						scope:headless_heir = {
							ai_boldness <= low_negative_ai_value
						}
						add = 15
					}
					modifier = {
						scope:headless_heir = {
							ai_boldness <= high_negative_ai_value
						}
						add = 30
					}
					modifier = {
						scope:headless_heir = {
							ai_honor <= low_negative_ai_value
						}
						add = 20
					}
					modifier = {
						scope:headless_heir = {
							ai_honor <= high_negative_ai_value
						}
						add = 40
					}
					modifier = {
						scope:headless_heir = {
							NOR = {
								government_has_flag = government_is_tribal
								government_has_flag = government_is_nomadic
							}
						}
						add = -20
					}
					hidden_effect = {
						scope:headless_heir = {
							#Prestige option does nothing to this char, add malus
							if = {
								limit = {
									scope:executioner = { has_character_flag = execution_head_prestige_flag }
								}
								if = {
									limit = {
										tier_difference = {
											target = scope:executioner
											value <= -2
										}
									}
									add_prestige = massive_prestige_loss
								}
								else_if = {
									limit = {
										tier_difference = {
											target = scope:executioner
											value <= -1
										}
									}
									add_prestige = major_prestige_loss
								}
								else = {
									add_prestige = medium_prestige_loss
								}
							}
							if = {
								limit = {
									mpo_keep_prisoners_heads_trigger = yes
									exists = scope:victim.house
								}
								scope:victim.house = {
									every_house_member = {
										custom = custom.every_house_member
										limit = {
											NOR = {
												this = scope:headless_heir
												this = scope:executioner
											}
										}
										add_opinion = {
											modifier = sullied_our_house_opinion
											target = scope:headless_heir
											opinion = -20
										}
									}
								}
							}
							create_character_memory = {
								type = sent_predecessors_head_memory
								participants = {
									executioner = scope:executioner
									victim = scope:victim
								}
							}
							
							add_character_flag = {
								flag = head_recipient_just_takes_it
								days = 30
							}
						}
					}
					show_as_tooltip = {
						mpo_nomad_events_1011_heir_cowed_effect = yes
					}
				}
				#they swear revenge
				50 = {
					desc = mpo_nomad_events.1011.b.fail
					modifier = {
						scope:headless_heir = {
							is_gurkhan = yes
						}
						add = 20
					}
					modifier = {
						scope:headless_heir = {
							tier_difference = {
								target = root
								value >= 1
							}
						}
						add = 20
					}
					modifier = {
						scope:headless_heir = {
							tier_difference = {
								target = root
								value >= 2
							}
						}
						add = 20
					}
					modifier = {
						scope:headless_heir = {
							tier_difference = {
								target = root
								value >= 3
							}
						}
						add = 20
					}
					modifier = {
						scope:headless_heir.top_liege = {
							tier_difference = {
								target = root.top_liege
								value >= 1
							}
						}
						add = 20
					}
					modifier = {
						scope:headless_heir.top_liege = {
							tier_difference = {
								target = root.top_liege
								value >= 2
							}
						}
						add = 20
					}
					modifier = {
						scope:headless_heir.top_liege = {
							tier_difference = {
								target = root.top_liege
								value >= 3
							}
						}
						add = 20
					}
					modifier = {
						scope:headless_heir = {
							current_military_strength > root.current_military_strength
						}
						add = 30
					}
					modifier = {
						scope:headless_heir = {
							max_military_strength > root.max_military_strength
						}
						add = 30
					}
					modifier = {
						scope:headless_heir.top_liege = {
							current_military_strength > root.top_liege.current_military_strength
						}
						add = 30
					}
					modifier = {
						scope:headless_heir.top_liege = {
							max_military_strength > root.top_liege.max_military_strength
						}
						add = 30
					}
					modifier = {
						scope:headless_heir = {
							legitimacy_level >= 4
						}
						add = 20
					}
					modifier = {
						scope:headless_heir = {
							has_trait = conqueror
						}
						add = 60
					}
					modifier = {
						scope:headless_heir = {
							has_trait = greatest_of_khans
						}
						add = 60
					}
					modifier = {
						scope:headless_heir = {
							ai_vengefulness >= low_positive_ai_value
						}
						add = 40
					}
					modifier = {
						scope:headless_heir = {
							ai_vengefulness >= high_positive_ai_value
						}
						add = 80
					}
					modifier = {
						scope:headless_heir = {
							ai_boldness >= low_positive_ai_value
						}
						add = 15
					}
					modifier = {
						scope:headless_heir = {
							ai_boldness >= high_positive_ai_value
						}
						add = 30
					}
					modifier = {
						scope:headless_heir = {
							ai_honor >= low_positive_ai_value
						}
						add = 20
					}
					modifier = {
						scope:headless_heir = {
							ai_honor >= high_positive_ai_value
						}
						add = 40
					}
					modifier = {
						scope:headless_heir = {
							OR = {
								government_has_flag = government_is_tribal
								government_has_flag = government_is_nomadic
							}
						}
						add = 20
					}
					show_as_tooltip = {
						scope:headless_heir = {
							mpo_nomad_events_1011_heir_resents_effect = yes
						}
					}
				}
			}
			#Receive letter event with response
			trigger_event = {
				id = mpo_nomad_events.1013
				days = 3
			}
		}
		#Players get event and will choose for themselves
		else = {
				custom_description_no_bullet = {
				text = headless_heir_ignores_challenge_tt
			}
			show_as_tooltip = {
				mpo_nomad_events_1011_heir_cowed_effect = yes
			}
			
			custom_description_no_bullet = {
				text = headless_heir_rises_to_challenge_tt
			}
			show_as_tooltip = {
				scope:headless_heir = {
					mpo_nomad_events_1011_heir_resents_effect = yes
				}
			}
			
			if = {
				limit = {
					scope:headless_heir.top_liege = {
						current_military_strength > scope:executioner.current_military_strength
						tier_difference = {
							target = scope:executioner
							value >= -1
						}
					}
				}
				custom_tooltip = headless_heir_high_tier_warning_tt
			}
			scope:headless_heir = {
				trigger_event = {
					id = mpo_nomad_events.1012
					days = 1
				}
			}
		}
		
		if = {
			limit = {
				scope:headless_heir = {
					max_military_strength > root.max_military_strength
				}
			}
			stress_impact = {
				craven = major_stress_impact_gain
				compassionate = medium_stress_impact_gain
				content = medium_stress_impact_gain
			}
		}
		stress_impact = {
			craven = minor_stress_impact_gain
			compassionate = medium_stress_impact_gain
			content = miniscule_stress_impact_gain
		}
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_compassion = -1
				ai_boldness = 1
			}
			modifier = {
				scope:headless_heir = {
					tier_difference = {
						target = root
						value >= 1
					}
				}
				add = -15
			}
			modifier = {
				scope:headless_heir = {
					tier_difference = {
						target = root
						value >= 2
					}
				}
				add = -15
			}
			modifier = {
				scope:headless_heir = {
					tier_difference = {
						target = root
						value >= 3
					}
				}
				add = -15
			}
			modifier = {
				scope:headless_heir.top_liege = {
					tier_difference = {
						target = root.top_liege
						value >= 1
					}
				}
				add = -15
			}
			modifier = {
				scope:headless_heir.top_liege = {
					tier_difference = {
						target = root.top_liege
						value >= 2
					}
				}
				add = -15
			}
			modifier = {
				scope:headless_heir.top_liege = {
					tier_difference = {
						target = root.top_liege
						value >= 3
					}
				}
				add = -15
			}
			modifier = {
				scope:headless_heir = {
					current_military_strength > root.current_military_strength
				}
				add = -25
			}
			modifier = {
				scope:headless_heir = {
					max_military_strength > root.max_military_strength
				}
				add = -25
			}
			modifier = {
				scope:headless_heir.top_liege = {
					current_military_strength > root.top_liege.current_military_strength
				}
				add = -25
			}
			modifier = {
				scope:headless_heir.top_liege = {
					max_military_strength > root.top_liege.max_military_strength
				}
				add = -25
			}
			modifier = {
				scope:headless_heir = {
					legitimacy_level >= 4
				}
				add = -15
			}
			modifier = {
				scope:headless_heir = {
					has_trait = conqueror
				}
				add = -50
			}
			modifier = {
				scope:headless_heir = {
					has_trait = greatest_of_khans
				}
				add = -50
			}
			modifier = {
				scope:headless_heir = {
					ai_vengefulness >= low_positive_ai_value
				}
				add = -30
			}
			modifier = {
				scope:headless_heir = {
					ai_vengefulness >= high_positive_ai_value
				}
				add = -60
			}
			modifier = {
				scope:headless_heir = {
					ai_boldness >= low_positive_ai_value
				}
				add = -15
			}
			modifier = {
				scope:headless_heir = {
					ai_boldness >= high_positive_ai_value
				}
				add = -30
			}
			modifier = {
				scope:headless_heir = {
					ai_honor >= low_positive_ai_value
				}
				add = -20
			}
			modifier = {
				scope:headless_heir = {
					ai_honor >= high_positive_ai_value
				}
				add = -40
			}
			modifier = {
				scope:headless_heir = {
					OR = {
						government_has_flag = government_is_tribal
						government_has_flag = government_is_nomadic
					}
				}
				add = -20
			}
			modifier = {
				scope:headless_heir = {
					has_dread_level_towards = {
						target = scope:executioner
						level >= 1
					}
				}
				add = 200
			}
			modifier = {
				scope:headless_heir = {
					has_dread_level_towards = {
						target = scope:executioner
						level >= 2
					}
				}
				add = 400
			}
			modifier = {
				OR = {
					has_trait = compassionate
					has_trait = content
				}
				add = -50
			}
			modifier = {
				OR = {
					has_trait = craven
					has_trait = compassionate
					has_trait = content
				}
				scope:headless_heir = {
					max_military_strength > root.max_military_strength
				}
				factor = 0
			}
		}
	}
	#Don't want to send or keep head
	option = {
		name = mpo_nomad_events.1011.c
		
		remove_execution_head_flags_effect = yes
		ai_chance = {
			base = 100
		}
	}
	after = {
		# Clear up flags
		scope:headless_heir = {
			if = {
				limit = {
					has_character_flag = house_feud_too_young_heir
				}
				remove_character_flag = house_feud_too_young_heir
			}
		}
	}
}

#You receive the severed head of your executed predecessor (mirror event)
mpo_nomad_events.1012 = {
	type = character_event
	theme = death
	title = mpo_nomad_events.1012.t
	desc = mpo_nomad_events.1012.desc
	override_background = {
		trigger = {
			NOR = {
				is_in_army = yes
				is_travelling = yes
			}
		}
		reference = throne_room
	}
	override_background = {
		trigger = {
			OR = {
				is_in_army = yes
				is_travelling = yes
			}
		}
		reference = bp1_bonfire
	}
	left_portrait = {
		character = root
		animation = wailing
		camera = camera_event_left_away_3_4
	}
	lower_right_portrait = scope:executioner
	lower_left_portrait = scope:victim

	immediate = {
		create_character_memory = {
			type = sent_predecessors_head_memory
			participants = {
				executioner = scope:executioner
				victim = scope:victim
			}
		}
	}
	
	#My predecessor was a great man: the most important thing is his head being honored
	option = {	
		trigger = {
			OR = {
				has_trait = lifestyle_mystic
				has_trait = theologian
				has_trait = zealous
				AND = {
					has_trait = pilgrim
					has_trait_xp = {
						trait = pilgrim
						value >= 50
					}
				}
				has_trait = devoted
			}
			OR = {
				faith.religion = faith:tengri_pagan.religion
				has_trait = nomadic_philosophy
				government_has_flag = government_is_nomadic
			}
		}
		name = mpo_nomad_events.1012.a
		flavor = mpo_nomad_events.1012.a_flavor
		show_as_tooltip = {
			scope:executioner = {
				mpo_nomad_events_1011_heir_cowed_effect = yes
			}
		}
		if = {
			limit = {
				scope:victim = {
					highest_held_title_tier >= tier_kingdom
				}
			}
			add_piety = major_piety_gain
		}
		else_if = {
			limit = {
				scope:victim = {
					highest_held_title_tier >= tier_duchy
				}
			}
			add_piety = medium_piety_gain
		}
		else = {
			add_piety = minor_piety_gain
		}
		#Prestige option does nothing to this char, add malus
		if = {
			limit = {
				scope:executioner = { has_character_flag = execution_head_prestige_flag }
			}
			if = {
				limit = {
					tier_difference = {
						target = scope:executioner
						value <= -2
					}
				}
				add_prestige = major_prestige_loss
			}
			else_if = {
				limit = {
					tier_difference = {
						target = scope:executioner
						value <= -1
					}
				}
				add_prestige = medium_prestige_loss
			}
			else = {
				add_prestige = minor_prestige_loss
			}
		}
		
		add_character_flag = {
			flag = head_recipient_just_takes_it
			days = 30
		}
		if = {
			limit = {
				mpo_nomad_events_1011_heir_unafraid_trigger = yes
			}
			stress_impact = {
				base = minor_stress_impact_loss
				forgiving = minor_stress_impact_loss
				calm = miniscule_stress_impact_loss
				vengeful = major_stress_impact_gain
				wrathful = major_stress_impact_gain
				just = major_stress_impact_gain
				stubborn = medium_stress_impact_gain
				sadistic = minor_stress_impact_gain
				brave = major_stress_impact_gain
			}
		}
		else = {
			stress_impact = {
				base = minor_stress_impact_loss
				forgiving = minor_stress_impact_loss
				calm = miniscule_stress_impact_loss
				vengeful = medium_stress_impact_gain
				wrathful = medium_stress_impact_gain
				just = minor_stress_impact_gain
				stubborn = miniscule_stress_impact_gain
				sadistic = miniscule_stress_impact_gain
				brave = minor_stress_impact_gain
			}
		}
	}
	#VENDETTA! VENDETTA!
	option = {
		name = mpo_nomad_events.1012.b
		flavor = mpo_nomad_events.1012.b_flavor
		show_as_tooltip = {
			mpo_nomad_events_1011_heir_resents_effect = yes
		}
		if = {
			limit = {
				mpo_nomad_events_1011_heir_unafraid_trigger = yes
			}
			stress_impact = {
				craven = minor_stress_impact_gain
				forgiving = minor_stress_impact_gain
				compassionate = miniscule_stress_impact_gain
				humble = miniscule_stress_impact_gain
				content = miniscule_stress_impact_gain
			}
		}
		else = {
			stress_impact = {
				craven = major_stress_impact_gain
				forgiving = major_stress_impact_gain
				compassionate = medium_stress_impact_gain
				calm = minor_stress_impact_gain
				humble = medium_stress_impact_gain
				content = medium_stress_impact_gain
			}
		}
	}
	#Yeah uh... this is gross and humiliating
	option = {
		name = mpo_nomad_events.1012.c
		show_as_tooltip = {
			scope:executioner = {
				mpo_nomad_events_1011_heir_cowed_effect = yes
			}
		}
		#Prestige option does nothing to this char, add malus
		if = {
			limit = {
				scope:executioner = { has_character_flag = execution_head_prestige_flag }
			}
			if = {
				limit = {
					tier_difference = {
						target = scope:executioner
						value <= -2
					}
				}
				add_prestige = massive_prestige_loss
			}
			else_if = {
				limit = {
					tier_difference = {
						target = scope:executioner
						value <= -1
					}
				}
				add_prestige = major_prestige_loss
			}
			else = {
				add_prestige = medium_prestige_loss
			}
		}
		if = {
			limit = {
				mpo_keep_prisoners_heads_trigger = yes
				exists = scope:victim.house
			}
			scope:victim.house = {
				every_house_member = {
					custom = custom.every_house_member
					limit = {
						NOR = {
							this = scope:headless_heir
							this = scope:executioner
						}
					}
					add_opinion = {
						modifier = sullied_our_house_opinion
						target = scope:headless_heir
						opinion = -20
					}
				}
			}
		}
		
		add_character_flag = {
			flag = head_recipient_just_takes_it
			days = 30
		}
		if = {
			limit = {
				mpo_nomad_events_1011_heir_unafraid_trigger = yes
			}
			stress_impact = {
				vengeful = major_stress_impact_gain
				wrathful = major_stress_impact_gain
				just = major_stress_impact_gain
				stubborn = medium_stress_impact_gain
				sadistic = minor_stress_impact_gain
				brave = major_stress_impact_gain
			}
		}
		else = {
			stress_impact = {
				vengeful = medium_stress_impact_gain
				wrathful = medium_stress_impact_gain
				just = minor_stress_impact_gain
				stubborn = miniscule_stress_impact_gain
				sadistic = miniscule_stress_impact_gain
				brave = minor_stress_impact_gain
			}
		}
	}
	after = {
		scope:executioner = {
			trigger_event = mpo_nomad_events.1013
		}
	}
}

mpo_nomad_events.1013 = {
	type = letter_event
	opening = {
		desc = mpo_nomad_events.1013
	}
	desc = {
		first_valid = {
			#Non-nomad desc
			triggered_desc = {
				trigger = {
					scope:headless_heir = {
						has_character_flag = head_recipient_just_takes_it
						mpo_keep_prisoners_heads_trigger = no
					}
				}
				desc = mpo_nomad_events.1013.desc_takes_it_sedentary
			}
			triggered_desc = {
				trigger = {
					scope:headless_heir = {
						has_character_flag = head_recipient_just_takes_it
					}
				}
				desc = mpo_nomad_events.1013.desc_takes_it
			}
			desc = mpo_nomad_events.1013.desc_angeee
		}
	}
	sender = scope:headless_heir

	trigger = {
		has_mpo_dlc_trigger = yes
		government_has_flag = government_is_nomadic
		is_alive = yes
		is_ruler = yes
		NOT = {
			is_imprisoned_by = scope:headless_heir
		}
		scope:headless_heir = {
			is_alive = yes
			is_ruler = yes
			NOT = {
				is_imprisoned_by = root
			}
		}
	}
	on_trigger_fail = {
		if = {
			limit = {
				scope:headless_heir = {
					has_character_flag = head_recipient_just_takes_it
				}
			}
			scope:headless_heir = {
				remove_character_flag = head_recipient_just_takes_it
			}
		}
		scope:executioner = {
			remove_execution_head_flags_effect = yes
		}
	}
	immediate = {
		#Apply effect of whatever they chose
		if = {
			limit = {
				scope:headless_heir = {
					has_character_flag = head_recipient_just_takes_it
				}
			}
			mpo_nomad_events_1011_heir_cowed_effect = yes
		}
		else = {
			scope:headless_heir = {
				mpo_nomad_events_1011_heir_resents_effect = yes
			}
		}
	}

	option = {
		name = {
			trigger = {
				scope:headless_heir = {
					has_character_flag = head_recipient_just_takes_it
				}
			}
			text = mpo_nomad_events.1013.a.cowed
		}
		name = {
			trigger = {
				scope:headless_heir = {
					NOT = { has_character_flag = head_recipient_just_takes_it }
				}
			}
			text = mpo_nomad_events.1013.a.revenge
		}
	}
	after = {
		if = {
			limit = {
				scope:headless_heir = {
					has_character_flag = head_recipient_just_takes_it
				}
			}
			scope:headless_heir = {
				remove_character_flag = head_recipient_just_takes_it
			}
		}
		scope:executioner = {
			remove_execution_head_flags_effect = yes
		}
	}
}

scripted_trigger mpo_nomad_events_1011_rowdy_boy_trigger = {
	is_adult = yes
	is_courtier_of = root
	is_imprisoned = no
	is_healthy = yes
	OR = {
		AND = {
			is_male = yes
			faith_dominant_gender_male_or_equal = yes
		}
		AND = {
			is_female = yes
			faith_dominant_gender_female_or_equal = yes
		}
	}
	OR = {
		AND = {
			ai_boldness > 0
			ai_energy > 0
		}
		AND = {
			opinion = {
				target = root
				value <= -30
			}
			ai_boldness >= medium_negative_ai_value
			ai_energy >= medium_negative_ai_value
		}
	}
	NOR = {
		has_trait = loyal
		is_primary_heir_of = root
		is_player_heir_of = root
		is_obedient_to = root
		has_dread_level_towards = {
			target = root
			level >= 2
		}
	}
	trigger_if = {
		limit = {
			has_variable = mpo_nomad_events_1020_liege
		}
		var:mpo_nomad_events_1020_liege = {
			NOT = {
				this = root
			}
		}
	}
}

scripted_trigger mpo_nomad_events_1011_rowdiest_trigger = {
	OR = {
		AND = {
			ai_boldness > medium_positive_ai_value
			ai_energy > medium_positive_ai_value
		}
		opinion = {
			target = root
			value < -60
		}
	}
	NOT = {
		has_dread_level_towards = {
			target = root
			level >= 1
		}
	}
	mpo_nomad_events_1011_rowdy_boy_trigger = yes
}

scripted_trigger mpo_nomad_events_1011_defecting_courtier_trigger = {
	save_temporary_scope_as = potential_defector
	is_adult = yes
	is_courtier_of = root
	is_acclaimed = no
	is_imprisoned = no
	ai_boldness > medium_negative_ai_value
	ai_energy > medium_negative_ai_value
	NOR = {
		is_in_list = defectors
		this = scope:rowdy_boy
		is_councillor_of = root
		is_consort_of = root
		has_trait = loyal
		is_primary_heir_of = root
		is_player_heir_of = root
		any_spouse = {
			OR = {
				is_councillor_of = root
				AND = {
					is_courtier_of = root
					has_any_court_position = yes
				}
				is_primary_heir_of = root
				is_player_heir_of = root
				is_acclaimed = yes
			}
		}
		has_any_court_position = yes
	}
	opinion = {
		target = root
		value <= 60
	}
	opinion = {
		target = scope:rowdy_boy
		value >= -40
	}
}

#Your adult family members want to break off and lead their own band
mpo_nomad_events.1020 = {
	type = character_event
	theme = nomads
	title = mpo_nomad_events.1020.t
	desc = mpo_nomad_events.1020.desc
	override_background = {
		reference = relaxing_room
	}
	left_portrait = {
		character = root
		animation = hunting_knife_start
	}
	right_portrait = {
		character = scope:rowdy_boy
		animation = war_attacker
		camera = camera_event_very_right
	}

	cooldown = {
		years = 5
	}

	trigger = {
		has_mpo_dlc_trigger = yes
		government_has_flag = government_is_nomadic
		OR = {
			has_realm_law = nomadic_authority_1
			has_realm_law = nomadic_authority_2
			has_realm_law = nomadic_authority_3
		}
		is_at_war = no
		has_raised_armies = no
		highest_held_title_tier >= tier_county
		is_available = yes
		is_healthy = yes
		OR = {
			any_child = {
				mpo_nomad_events_1011_rowdy_boy_trigger = yes
			}
			any_sibling = {
				mpo_nomad_events_1011_rowdy_boy_trigger = yes
			}
		}
	}

	weight_multiplier = {
		base = 1
		modifier = {
			add = 2
			has_realm_law = nomadic_authority_1
		}
		modifier = {
			add = 2
			has_realm_law = nomadic_authority_2
		}
		modifier = {
			add = 2
			domicile ?= {
				herd >= max_herd
			}
		}

		#weight up if family member very much wants to leave
		modifier = {
			add = 3
			OR = {
				any_child = {
					mpo_nomad_events_1011_rowdiest_trigger = yes
				}
				any_sibling = {
					mpo_nomad_events_1011_rowdiest_trigger = yes
				}
			}
		}
		modifier = {
			add = 1
			legitimacy_level < 1
		}
		modifier = {
			add = -1
			legitimacy_level >= 5
		}
		#Weight up/down culturally
		modifier = {
			add = 1
			culture = {
				has_cultural_pillar = ethos_bellicose
			}
		}
		modifier = {
			add = -1
			culture = {
				has_cultural_pillar = ethos_communal
			}
		}
		#Very likely to happen after a succession leaves someone landless
		modifier = {
			add = 2
			primary_title = {
				title_held_years < 5
			}
		}
		modifier = {
			add = 1
			has_variable = recently_lost_wars
		}
		min = 1
	}

	immediate = {
		random_sibling = {
			limit = {
				mpo_nomad_events_1011_rowdiest_trigger = yes
			}
			save_scope_as = rowdy_boy
		}
		if = {
			limit = {
				NOT = {
					exists = scope:rowdy_boy
				}
			}
			random_child = {
				limit = {
					mpo_nomad_events_1011_rowdiest_trigger = yes
				}
				save_scope_as = rowdy_boy
			}
		}
		if = {
			limit = {
				NOT = {
					exists = scope:rowdy_boy
				}
			}
			random_sibling = {
				limit = {
					mpo_nomad_events_1011_rowdy_boy_trigger = yes
				}
				save_scope_as = rowdy_boy
			}
		}
		if = {
			limit = {
				NOT = {
					exists = scope:rowdy_boy
				}
			}
			random_child = {
				limit = {
					mpo_nomad_events_1011_rowdy_boy_trigger = yes
				}
				save_scope_as = rowdy_boy
			}
		}
		#Make list of defectors
		scope:rowdy_boy = {
			every_consort = {
				limit = {
					is_ruler = no
				}
				add_to_list = defectors
			}
			every_child = {
				limit = {
					is_ruler = no
				}
				add_to_list = defectors
			}
		}
		random_courtier = {
			limit = {
				mpo_nomad_events_1011_defecting_courtier_trigger = yes	
			}
			add_to_list = defectors
		}
		random_courtier = {
			limit = {
				mpo_nomad_events_1011_defecting_courtier_trigger = yes	
			}
			add_to_list = defectors
		}
		random_courtier = {
			limit = {
				mpo_nomad_events_1011_defecting_courtier_trigger = yes	
			}
			add_to_list = defectors
		}
		#Add all the kids and spouses of defectors
		every_in_list = {
			list = defectors
			every_child = {
				limit = {
					save_temporary_scope_as = potential_defector
					is_courtier_of = root
					is_acclaimed = no
					is_imprisoned = no
					NOR = {
						this = scope:rowdy_boy
						is_councillor_of = root
						is_consort_of = root
						is_primary_heir_of = root
						is_player_heir_of = root
						any_spouse ?= {
							save_temporary_scope_as = potential_defector_spouse
							is_councillor_of = root
						}
						any_spouse ?= {
							OR = {
								is_primary_heir_of = root
								is_player_heir_of = root
							}
						}
						any_spouse ?= {
							is_acclaimed = yes
						}
						root = {
							any_court_position_holder = {
								this = scope:potential_defector
							}
						}
						root = {
							any_court_position_holder = {
								this ?= scope:potential_defector_spouse
							}
						}
					}
				}
				add_to_list = defectors
				every_spouse = {
					limit = {
						save_temporary_scope_as = potential_defector
						is_courtier_of = root
						is_acclaimed = no
						is_imprisoned = no
						NOR = {
							this = scope:rowdy_boy
							is_councillor_of = root
							is_consort_of = root
							is_primary_heir_of = root
							is_player_heir_of = root
							root = {
								any_court_position_holder = {
									this = scope:potential_defector
								}
							}
						}
					}
					add_to_list = defectors
				}
				every_child = {
					limit = {
						save_temporary_scope_as = potential_defector
						is_courtier_of = root
						is_acclaimed = no
						is_imprisoned = no
						NOR = {
							this = scope:rowdy_boy
							is_councillor_of = root
							is_consort_of = root
							is_primary_heir_of = root
							is_player_heir_of = root
							root = {
								any_court_position_holder = {
									this = scope:potential_defector
								}
							}
						}
					}
					add_to_list = defectors
				}
			}
			every_spouse = {
				limit = {
					NOR = {
						this = scope:rowdy_boy
						this = root
					}
				}
				add_to_list = defectors
			}
		}
		#Save title if possible
		if = {
			limit = {
				any_held_title = {
					tier = tier_county
					is_landless_type_title = no
					NOR = {
						this = root.capital_county
						this = root.primary_title
						duchy = {
							this = root.capital_county.duchy
						}
					}
				}
			}
			random_held_title = {
				limit = {
					tier = tier_county
					is_landless_type_title = no
					NOR = {
						this = root.capital_county
						this = root.primary_title
						duchy = {
							this = root.capital_county.duchy
						}
					}
				}
				save_scope_as = rowdy_title
			}
		}
		else_if = {
			limit = {
				any_held_title = {
					tier = tier_county
					is_landless_type_title = no
					NOR = {
						this = root.capital_county
						this = root.primary_title
					}
				}
			}
			random_held_title = {
				limit = {
					tier = tier_county
					is_landless_type_title = no
					NOR = {
						this = root.capital_county
						this = root.primary_title
					}
				}
				save_scope_as = rowdy_title
			}
		}
		save_scope_as = root_scope
		scope:rowdy_boy = {
			set_variable = {
				name = mpo_nomad_events_1020_liege
				value = root
				years = 25
			}
		}	
	}

	#Great Khan/Conqueror better forbidding option
	option = {
		name = mpo_nomad_events.1020.a
		trigger = {
			OR = {
				has_trait = conqueror
				has_trait = greatest_of_khans
				has_realm_law = nomadic_authority_5
			}
		}
		add_legitimacy = minor_legitimacy_gain
		scope:rowdy_boy = {
			add_opinion = {
				modifier = humiliated_opinion
				target = root
				opinion = -30
			}
		}
		stress_impact = {
			generous = medium_stress_impact_gain
			compassionate = minor_stress_impact_gain
			humble = minor_stress_impact_gain
		}
		ai_chance = {
			base = 400
			ai_value_modifier = {
				ai_compassion = -1
				ai_greed = 1
			}
			modifier = {
				opinion = {
					target = scope:rowdy_boy
					value >= 80
				}
				add = -50
			}
			modifier = {
				opinion = {
					target = scope:rowdy_boy
					value < 0
				}
				add = -25
			}
			modifier = {
				opinion = {
					target = scope:rowdy_boy
					value < -50
				}
				add = 50
			}
			modifier = {
				opinion = {
					target = scope:rowdy_boy
					value < -75
				}
				add = 100
			}
			modifier = {
				OR = {
					has_trait = compassionate
					has_trait = humble
				}
				add = -100
			}
			modifier = {
				has_trait = generous
				factor = 0
			}
		}
	}

	#Kill him
	option = {
		name = mpo_nomad_events.1020.b
		trigger = {
			is_adult = yes
			is_incapable = no
			can_be_combatant_based_on_gender_trigger = { ARMY_OWNER = root }
			scope:rowdy_boy = {
				can_be_combatant_based_on_gender_trigger = { ARMY_OWNER = root }
			}
			OR = {
				AND = {
					has_trait = tourney_participant
					has_trait_xp = {
						trait = tourney_participant
						track = foot
						value > 0
					}
				}
				has_trait = berserker
				has_trait = gallant
				has_trait = lifestyle_blademaster
				has_trait = shieldmaiden
				has_trait = brave
				has_trait = wrathful
				has_trait = callous
				has_trait = sadistic
				has_trait = vengeful
				has_trait = arrogant
				has_trait = arbitrary
				has_trait = paranoid
				has_trait = fickle
				has_trait = stubborn
				has_trait = just
				has_trait = ambitious
			}
		}
		add_internal_flag = dangerous
		custom_tooltip = mpo_nomad_events.1020_duel_tt
		add_character_flag = {
			flag = duelling_defecting_family_flag
			months = 6
		}
		configure_start_single_combat_effect = {
			SC_INITIATOR = root
			SC_ATTACKER = root
			SC_DEFENDER = scope:rowdy_boy
			FATALITY = always
			FIXED = no
			LOCALE = terrain_scope
			OUTPUT_EVENT = mpo_nomad_events.1021
			INVALIDATION_EVENT = perk_interaction.0102
		}
		if = {
			limit = {
				has_relation_blood_brother = scope:rowdy_boy
			}
			add_stress = major_stress_impact_gain
			remove_relation_blood_brother = scope:rowdy_boy
		}
		if = {
			limit = {
				has_relation_friend = scope:rowdy_boy
			}
			add_stress = medium_stress_impact_gain
			remove_relation_friend = scope:rowdy_boy
		}
		if = {
			limit = {
				has_relation_best_friend = scope:rowdy_boy
			}
			add_stress = major_stress_impact_gain
			remove_relation_best_friend = scope:rowdy_boy
		}
		if = {
			limit = {
				has_relation_soulmate = scope:rowdy_boy
			}
			add_stress = major_stress_impact_gain
			remove_relation_soulmate = scope:rowdy_boy
		}
		house = {
			every_house_member = {
				limit = {
					NOT = {
						this = root
					}
				}
				custom = custom.every_house_member
				add_opinion = {
					target = root
					modifier = attacked_family_opinion
					opinion = -25
				}
			}
		}
		
		stress_impact = {
			forgiving = major_stress_impact_gain
			generous = major_stress_impact_gain
			craven = major_stress_impact_gain
			compassionate = major_stress_impact_gain
			trusting = medium_stress_impact_gain
			humble = minor_stress_impact_gain
			loyal = medium_stress_impact_gain
		}
		ai_chance = {
			base = 25
			ai_value_modifier = {
				ai_vengefulness = 1
				ai_compassion = -1
			}
			modifier = {
				opinion = {
					target = scope:rowdy_boy
					value >= 80
				}
				add = -50
			}
			modifier = {
				opinion = {
					target = scope:rowdy_boy
					value < 0
				}
				add = -25
			}
			modifier = {
				opinion = {
					target = scope:rowdy_boy
					value < -50
				}
				add = 50
			}
			modifier = {
				opinion = {
					target = scope:rowdy_boy
					value < -75
				}
				add = 100
			}
			modifier = {
				prowess > scope:rowdy_boy.prowess
				add = 25
			}
			modifier = {
				prowess >= high_skill_rating
				scope:rowdy_boy.prowess <= average_skill_rating
				add = 50
			}
			modifier = {
				prowess >= very_high_skill_rating
				scope:rowdy_boy.prowess <= average_skill_rating
				add = 50
			}
			modifier = {
				prowess >= decent_skill_rating
				scope:rowdy_boy.prowess <= low_skill_rating
				add = 50
			}
			modifier = {
				prowess >= extremely_high_skill_rating
				scope:rowdy_boy.prowess <= high_skill_rating
				add = 50
			}
			modifier = {
				prowess < scope:rowdy_boy.prowess
				add = -25
			}
			modifier = {
				scope:rowdy_boy.prowess >= high_skill_rating
				prowess <= average_skill_rating
				add = -50
			}
			modifier = {
				scope:rowdy_boy.prowess >= very_high_skill_rating
				prowess <= average_skill_rating
				add = -50
			}
			modifier = {
				scope:rowdy_boy.prowess >= decent_skill_rating
				prowess <= low_skill_rating
				add = -50
			}
			modifier = {
				scope:rowdy_boy.prowess >= extremely_high_skill_rating
				prowess <= high_skill_rating
				add = -50
			}
			modifier = {
				has_trait = humble
				add = -100
			}
			modifier = {
				trait_is_criminal_in_faith_trigger = { FAITH = root.faith TRAIT = kinslayer_3 GENDER_CHARACTER = root }
				add = -25
			}
			modifier = {
				NOT = {
					trait_is_shunned_or_criminal_in_faith_trigger = { FAITH = root.faith TRAIT = kinslayer_3 GENDER_CHARACTER = root }
				}
				add = 50
			}
			modifier = {
				OR = {
					has_trait = generous
					has_trait = forgiving
					has_trait = compassionate
					has_trait = trusting
					has_trait = loyal
					has_trait = craven
				}
				factor = 0
			}
		}
	}

	#Make them a landed vassal
	option = {
		name = mpo_nomad_events.1020.c
		flavor = mpo_nomad_events.1020.c.flavor
		trigger = {
			exists = scope:rowdy_title
			highest_held_title_tier > tier_county
		}
		add_internal_flag = special
		create_title_and_vassal_change = {
			type = granted
			save_scope_as = change
		}
		if = {
			limit = {
				domain_size >= 6
			}
			add_legitimacy = miniscule_legitimacy_gain
		}
		else_if = {
			limit = {
				domain_size >= 4
			}
			add_legitimacy = minor_legitimacy_gain
		}
		else_if = {
			limit = {
				domain_size >= 3
			}
			add_legitimacy = medium_legitimacy_gain
		}
		else = {
			add_legitimacy = major_legitimacy_gain
		}
		
		scope:rowdy_title = {
			change_title_holder = {
				holder = scope:rowdy_boy
				change = scope:change
			}
		}
		scope:rowdy_boy = {
			add_opinion = {
				target = root
				modifier = received_title_county
				opinion = 40
			}
			progress_towards_friend_effect = {
				REASON = friend_granted_title
				CHARACTER = root
				OPINION = 0
			}
			add_opinion = {
				modifier = obedience_opinion
				target = root
			}
		}
		resolve_title_and_vassal_change = scope:change
		
		if = {
			limit = {
				highest_held_title_tier <= tier_duchy
			}
			pay_herd = {
				target = scope:rowdy_boy
				value = domicile.twenty_percent_current_herd_value
			}
		}
		else_if = {
			limit = {
				highest_held_title_tier <= tier_kingdom
			}
			pay_herd = {
				target = scope:rowdy_boy
				value = domicile.fifteen_percent_current_herd_value
			}
		}
		else = {
			pay_herd = {
				target = scope:rowdy_boy
				value = domicile.ten_percent_current_herd_value
			}
		}

		stress_impact = {
			greedy = major_stress_impact_gain
			ambitious = minor_stress_impact_gain
			vengeful = minor_stress_impact_gain
			paranoid = minor_stress_impact_gain
		}
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_greed = -1
				ai_vengefulness = -0.5
			}
			modifier = {
				opinion = {
					target = scope:rowdy_boy
					value >= 50
				}
				add = 25
			}
			modifier = {
				opinion = {
					target = scope:rowdy_boy
					value >= 80
				}
				add = 50
			}
			modifier = {
				opinion = {
					target = scope:rowdy_boy
					value < 0
				}
				add = 25
			}
			modifier = {
				opinion = {
					target = scope:rowdy_boy
					value < -50
				}
				add = -50
			}
			modifier = {
				opinion = {
					target = scope:rowdy_boy
					value < -75
				}
				add = -100
			}
			modifier = {
				domain_limit_available <= 0
				add = 100
			}
			modifier = {
				domain_limit_available >= 2
				add = -50
			}
			modifier = {
				domain_size >= 6
				add = 100
			}
			modifier = {
				domain_size <= 3
				add = -100
			}
			modifier = {
				OR = {
					has_trait = paranoid
					has_trait = ambitious
					has_trait = vengeful
				}
				add = -100
			}
			modifier = {
				OR = {
					has_trait = greedy
					gold < medium_gold_value
					domain_size <= 2
				}
				factor = 0
			}
		}
	}

	#Let them go
	option = {
		name = mpo_nomad_events.1020.d
		flavor = mpo_nomad_events.1020.d.flavor
		if = {
			limit = {
				any_maa_regiment = {
					maa_size >= 12
				}
			}
			scope:rowdy_boy = {
				add_prestige = massive_prestige_gain
			}
			dynasty = {
				add_dynasty_prestige = massive_dynasty_prestige_gain
			}
		}
		else_if = {
			limit = {
				any_maa_regiment = {
					maa_size >= 8
				}
			}
			scope:rowdy_boy = {
				add_prestige = major_prestige_gain
			}
			dynasty = {
				add_dynasty_prestige = major_dynasty_prestige_gain
			}
		}
		else_if = {
			limit = {
				any_maa_regiment = {
					maa_size >= 4
				}
			}
			scope:rowdy_boy = {
				add_prestige = medium_prestige_gain
			}
			dynasty = {
				add_dynasty_prestige = medium_dynasty_prestige_gain
			}
		}
		else = {
			scope:rowdy_boy = {
				add_prestige = minor_prestige_gain
			}
			dynasty = {
				add_dynasty_prestige = minor_dynasty_prestige_gain
			}
		}
		
		remove_courtier_or_guest = scope:rowdy_boy
		scope:rowdy_boy = {
			save_scope_as = holder
			create_nomad_title = {
				name = nomad_title_name
				holder = scope:rowdy_boy
				government = nomad_government
				save_scope_as = new_nomad_title
			}
			change_government = nomad_government
			
			progress_towards_friend_effect = {
				REASON = friend_granted_following
				CHARACTER = root
				OPINION = 0
			}
			add_opinion = {
				target = root
				modifier = grateful_opinion
				opinion = 60
			}
			if = {
				limit = {
					any_in_list = {
						list = defectors
						is_courtier_of = root
					}
				}
				hidden_effect = {
					every_in_list = {
						list = defectors
						limit = {
							is_courtier_of = root
						}
						scope:rowdy_boy = {
							add_courtier = prev
						}
						set_variable = {
							name = nomad_defector_var
							value = root
							years = 5
						}
					}
				}
				if = {
					limit = {
						any_in_list = {
							list = defectors
							OR = {
								is_child_of = scope:rowdy_boy
								is_spouse_of = scope:rowdy_boy
							}
							is_courtier_of = scope:rowdy_boy
						}
					}
					custom_tooltip = nomad_defector_family_tt
				}
				if = {
					limit = {
						any_in_list = {
							list = defectors
							NOR = {
								is_child_of = scope:rowdy_boy
								is_spouse_of = scope:rowdy_boy
							}
							is_courtier_of = root
						}
					}
					custom_tooltip = nomad_defector_gain_all_courtiers_tt
				}
			}
			create_character_memory = {
				type = defected_from_kin_memory
				participants = {
					kin = root
				}
			}
		}
		if = {
			limit = {
				highest_held_title_tier <= tier_duchy
			}
			pay_herd = {
				target = scope:rowdy_boy
				value = domicile.twenty_percent_current_herd_value
			}
		}
		else_if = {
			limit = {
				highest_held_title_tier <= tier_kingdom
			}
			pay_herd = {
				target = scope:rowdy_boy
				value = domicile.fifteen_percent_current_herd_value
			}
		}
		else = {
			pay_herd = {
				target = scope:rowdy_boy
				value = domicile.ten_percent_current_herd_value
			}
		}
		if = {
			limit = {
				any_maa_regiment = {
					maa_size > 12
				}
			}
			ordered_maa_regiment = {
				order_by = maa_size
				limit = {
					maa_size > 12
				}
				change_maa_regiment_size = {
					size = -6
					reinforce = yes
				}
				scope:rowdy_boy = {
					create_maa_regiment = {
						type_of = prev
						size = 6
					}
				}
			}
		}
		else_if = {
			limit = {
				any_maa_regiment = {
					maa_size > 10
				}
			}
			ordered_maa_regiment = {
				order_by = maa_size
				limit = {
					maa_size > 10
				}
				change_maa_regiment_size = {
					size = -5
					reinforce = yes
				}
				scope:rowdy_boy = {
					create_maa_regiment = {
						type_of = prev
						size = 5
					}
				}
			}
		}
		else_if = {
			limit = {
				any_maa_regiment = {
					maa_size > 8
				}
			}
			ordered_maa_regiment = {
				order_by = maa_size
				limit = {
					maa_size > 8
				}
				change_maa_regiment_size = {
					size = -4
					reinforce = yes
				}
				scope:rowdy_boy = {
					create_maa_regiment = {
						type_of = prev
						size = 4
					}
				}
			}
		}
		else_if = {
			limit = {
				any_maa_regiment = {
					maa_size > 6
				}
			}
			ordered_maa_regiment = {
				order_by = maa_size
				limit = {
					maa_size > 6
				}
				change_maa_regiment_size = {
					size = -3
					reinforce = yes
				}
				scope:rowdy_boy = {
					create_maa_regiment = {
						type_of = prev
						size = 3
					}
				}
			}
		}
		else_if = {
			limit = {
				any_maa_regiment = {
					maa_size > 4
				}
			}
			ordered_maa_regiment = {
				order_by = maa_size
				limit = {
					maa_size > 4
				}
				change_maa_regiment_size = {
					size = -2
					reinforce = yes
				}
				scope:rowdy_boy = {
					create_maa_regiment = {
						type_of = prev
						size = 2
					}
				}
			}
		}
		else_if = {
			limit = {
				any_maa_regiment = {
					maa_size > 2
				}
			}
			ordered_maa_regiment = {
				order_by = maa_size
				limit = {
					maa_size > 2
				}
				change_maa_regiment_size = {
					size = -1
					reinforce = yes
				}
				scope:rowdy_boy = {
					create_maa_regiment = {
						type_of = prev
						size = 1
					}
				}
			}
		}
		stress_impact = {
			greedy = major_stress_impact_gain
			arrogant = medium_stress_impact_gain
			ambitious = medium_stress_impact_gain
			vengeful = minor_stress_impact_gain
		}
		ai_chance = {
			base = 0
			ai_value_modifier = {
				ai_greed = -1
				ai_vengefulness = -0.5
			}
			modifier = {
				opinion = {
					target = scope:rowdy_boy
					value >= 50
				}
				add = 25
			}
			modifier = {
				opinion = {
					target = scope:rowdy_boy
					value >= 80
				}
				add = 50
			}
			modifier = {
				opinion = {
					target = scope:rowdy_boy
					value < 0
				}
				add = 25
			}
			modifier = {
				opinion = {
					target = scope:rowdy_boy
					value < -50
				}
				add = -50
			}
			modifier = {
				opinion = {
					target = scope:rowdy_boy
					value < -75
				}
				add = -100
			}
			modifier = {
				OR = {
					has_trait = greedy
					has_trait = arrogant
					has_trait = ambitious
					gold <= major_gold_value
				}
				factor = 0
			}
		}
	}

	#Try to convince them to stay
	option = {
		name = mpo_nomad_events.1020.e
		trigger = {
			NOR = {
				has_trait = conqueror
				has_trait = greatest_of_khans
				has_realm_law = nomadic_authority_5
				has_realm_law = nomadic_authority_4
			}
		}
		duel = {
			skills = { diplomacy intrigue }
			target = scope:rowdy_boy
			#You talk him down
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = -49
				}
				modifier = {
					legitimacy_level >= 5
					add = 10
				}
				modifier = {
					legitimacy_level >= 4
					add = 10
				}
				modifier = {
					scope:rowdy_boy = {
						opinion = {
							target = root
							value >= 75
						}
					}
					add = 25
				}
				desc = mpo_nomad_events.1020.e.success
				send_interface_toast = {
					title = mpo_nomad_events.1020.e.success
					left_icon = scope:rowdy_boy
					
					if = {
						limit = {
							has_lifestyle = diplomacy_lifestyle
						}
						add_diplomacy_lifestyle_xp = major_lifestyle_xp
					}
					else_if = {
						limit = {
							has_lifestyle = intrigue_lifestyle
						}
						add_intrigue_lifestyle_xp = major_lifestyle_xp
					}
					else = {
						add_legitimacy = minor_legitimacy_gain
						scope:rowdy_boy = {
							add_opinion = {
								target = root
								modifier = pacified_opinion
								opinion = 30
							}
						}
					}
					scope:rowdy_boy = {
						add_opinion = {
							modifier = obedience_opinion
							target = root
						}
					}
				}
			}
			#He and his supporters sneak off
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = -49
				}
				modifier = {
					scope:rowdy_boy = {
						mpo_nomad_events_1011_rowdiest_trigger = yes
					}
					add = 50
				}
				modifier = {
					legitimacy_level < 1
					add = 10
				}
				modifier = {
					legitimacy_level <= 1
					add = 10
				}
				modifier = {
					legitimacy_level <= 2
					add = 10
				}
				modifier = {
					scope:rowdy_boy = {
						opinion = {
							target = root
							value <= -25
						}
					}
					add = 25
				}
				desc = mpo_nomad_events.1020.e.failure
				send_interface_toast = {
					title = mpo_nomad_events.1020.e.failure
					left_icon = scope:rowdy_boy
					
					scope:rowdy_boy = {
						save_scope_as = holder
						create_nomad_title = {
							name = nomad_title_name
							holder = scope:rowdy_boy
							government = nomad_government
							save_scope_as = new_nomad_title
						}
						change_government = nomad_government
						add_opinion = {
							target = root
							modifier = disrespect_opinion
							opinion = -30
						}
						set_variable = {
							name = nomad_defector_var
							value = root
							years = 5
						}
						if = {
							limit = {
								any_in_list = {
									list = defectors
									is_courtier_of = root
								}
							}
							hidden_effect = {
								every_in_list = {
									list = defectors
									limit = {
										is_courtier_of = root
									}
									scope:rowdy_boy = {
										add_courtier = prev
									}
									set_variable = {
										name = nomad_defector_var
										value = root
										years = 5
									}
								}
							}
							if = {
								limit = {
									any_in_list = {
										list = defectors
										OR = {
											is_child_of = scope:rowdy_boy
											is_spouse_of = scope:rowdy_boy
										}
										is_courtier_of = scope:rowdy_boy
									}
								}
								custom_tooltip = nomad_defector_family_tt
							}
							if = {
								limit = {
									any_in_list = {
										list = defectors
										NOR = {
											is_child_of = scope:rowdy_boy
											is_spouse_of = scope:rowdy_boy
										}
										is_courtier_of = root
									}
								}
								custom_tooltip = nomad_defector_gain_all_courtiers_tt
							}
						}
						custom_tooltip = nomad_defector_family_wont_come_back_tt
						create_character_memory = {
							type = defected_from_kin_memory
							participants = {
								kin = root
							}
						}

					}
					if = {
						limit = {
							highest_held_title_tier <= tier_duchy
						}
						pay_herd = {
							target = scope:rowdy_boy
							value = domicile.ten_percent_current_herd_value
						}
					}
					else = {
						pay_herd = {
							target = scope:rowdy_boy
							value = domicile.five_percent_current_herd_value
						}
					}
					if = {
						limit = {
							any_maa_regiment = {
								maa_size > 15
							}
						}
						ordered_maa_regiment = {
							order_by = maa_size
							limit = {
								maa_size > 15
							}
							change_maa_regiment_size = {
								size = -6
								reinforce = yes
							}
							scope:rowdy_boy = {
								create_maa_regiment = {
									type_of = prev
									size = 6
								}
							}
						}
					}
					else_if = {
						limit = {
							any_maa_regiment = {
								maa_size > 12
							}
						}
						ordered_maa_regiment = {
							order_by = maa_size
							limit = {
								maa_size > 12
							}
							change_maa_regiment_size = {
								size = -5
								reinforce = yes
							}
							scope:rowdy_boy = {
								create_maa_regiment = {
									type_of = prev
									size = 5
								}
							}
						}
					}
					else_if = {
						limit = {
							any_maa_regiment = {
								maa_size > 10
							}
						}
						ordered_maa_regiment = {
							order_by = maa_size
							limit = {
								maa_size > 10
							}
							change_maa_regiment_size = {
								size = -4
								reinforce = yes
							}
							scope:rowdy_boy = {
								create_maa_regiment = {
									type_of = prev
									size = 4
								}
							}
						}
					}
					else_if = {
						limit = {
							any_maa_regiment = {
								maa_size > 8
							}
						}
						ordered_maa_regiment = {
							order_by = maa_size
							limit = {
								maa_size > 8
							}
							change_maa_regiment_size = {
								size = -3
								reinforce = yes
							}
							scope:rowdy_boy = {
								create_maa_regiment = {
									type_of = prev
									size = 3
								}
							}
						}
					}
					else_if = {
						limit = {
							any_maa_regiment = {
								maa_size > 6
							}
						}
						ordered_maa_regiment = {
							order_by = maa_size
							limit = {
								maa_size > 6
							}
							change_maa_regiment_size = {
								size = -2
								reinforce = yes
							}
							scope:rowdy_boy = {
								create_maa_regiment = {
									type_of = prev
									size = 2
								}
							}
						}
					}
					else_if = {
						limit = {
							any_maa_regiment = {
								maa_size > 4
							}
						}
						ordered_maa_regiment = {
							order_by = maa_size
							limit = {
								maa_size > 4
							}
							change_maa_regiment_size = {
								size = -1
								reinforce = yes
							}
							scope:rowdy_boy = {
								create_maa_regiment = {
									type_of = prev
									size = 1
								}
							}
						}
					}
				}
			}
		}
		stress_impact = {
			paranoid = minor_stress_impact_gain
		}
		ai_chance = {
			base = 0
			ai_value_modifier = {
				ai_sociability = 1
			}
			modifier = {
				AND = {
					diplomacy > scope:rowdy_boy.diplomacy
					intrigue > scope:rowdy_boy.intrigue
				}
				add = 25
			}
			modifier = {
				OR = {
					AND = {
						diplomacy >= high_skill_rating
						intrigue >= high_skill_rating
					}
					diplomacy > extremely_high_skill_rating
					intrigue > extremely_high_skill_rating
				}
				add = 25
			}
			modifier = {
				scope:rowdy_boy = {
					OR = {
						AND = {
							diplomacy < average_skill_rating
							intrigue < average_skill_rating
						}
						diplomacy <= low_skill_rating
						intrigue <= low_skill_rating
					}
				}
				add = 25
			}
			modifier = {
				AND = {
					diplomacy < scope:rowdy_boy.diplomacy
					intrigue < scope:rowdy_boy.intrigue
				}
				add = -25
			}
			modifier = {
				scope:rowdy_boy = {
					OR = {
						AND = {
							diplomacy >= high_skill_rating
							intrigue >= high_skill_rating
						}
						diplomacy > extremely_high_skill_rating
						intrigue > extremely_high_skill_rating
					}
				}
				add = -25
			}
			modifier = {
				OR = {
					AND = {
						diplomacy < average_skill_rating
						intrigue < average_skill_rating
					}
					diplomacy <= low_skill_rating
					intrigue <= low_skill_rating
				}
				add = -25
			}
			modifier = {
				diplomacy < high_skill_rating
				intrigue < high_skill_rating
				scope:rowdy_boy = {
					diplomacy >= low_skill_rating
					intrigue >= low_skill_rating
				}
				add = -25
			}
			modifier = {
				scope:rowdy_boy = {
					mpo_nomad_events_1011_rowdiest_trigger = yes
				}
				add = -50
			}
			modifier = {
				legitimacy_level < 1
				add = -10
			}
			modifier = {
				legitimacy_level <= 1
				add = -10
			}
			modifier = {
				legitimacy_level <= 2
				add = -10
			}
			modifier = {
				scope:rowdy_boy = {
					opinion = {
						target = root
						value <= -25
					}
				}
				add = -25
			}
			modifier = {
				legitimacy_level >= 5
				add = 10
			}
			modifier = {
				legitimacy_level >= 4
				add = 10
			}
			modifier = {
				scope:rowdy_boy = {
					opinion = {
						target = root
						value >= 75
					}
				}
				add = 25
			}
		}
	}
	#Send them alone into exile
	option = {
		name = mpo_nomad_events.1020.f
		flavor = mpo_nomad_events.1020.f.flavor
		
		add_dread = minor_dread_gain
		create_character_memory = {
			type = exiled_kin_memory
			participants = {
				exile = scope:rowdy_boy
			}
		}
		scope:rowdy_boy = {
			progress_towards_rival_effect = {
				REASON = rival_banished_kin
				CHARACTER = root
				OPINION = 0
			}
			add_opinion = {
				modifier = banished_me
				target = root
				opinion = -40
			}
			set_variable = {
				name = nomad_defector_var
				value = root
				years = 5
			}
			create_character_memory = {
				type = exiled_by_kin_memory
				participants = {
					banisher = root
				}
			}
		}
		remove_courtier_or_guest = scope:rowdy_boy
		hidden_effect = {
			every_in_list = {
				list = defectors
				limit = {
					OR = {
						is_child_of = scope:rowdy_boy
						is_spouse_of = scope:rowdy_boy
					}
				}
				if = {
					limit = {
						OR = {
							is_courtier_of = root
							is_pool_guest_of = root
						}	
					}
					root = {
						remove_courtier_or_guest = prev
					}
				}
				set_variable = {
					name = nomad_defector_var
					value = root
					years = 5
				}
			}
		}
		if = {
			limit = {
				any_in_list = {
					list = defectors
					OR = {
						is_child_of = scope:rowdy_boy
						is_spouse_of = scope:rowdy_boy
					}
				}
			}
			custom_tooltip = nomad_defector_family_tt
			custom_tooltip = nomad_defector_family_wont_come_back_tt
		}
		else = {
			custom_tooltip = nomad_defector_wont_come_back_tt
		}
		#Move exiles from root's capital
		hidden_effect = {
			if = {
				limit = {
					any_neighboring_and_across_water_top_liege_realm_owner = {
						exists = capital_province
					}
				}
				random_neighboring_and_across_water_top_liege_realm_owner = {
					limit = {
						exists = capital_province
					}
					capital_province = {
						save_scope_as = exile_destination
					}
				}
				scope:rowdy_boy = {
					move_to_pool_at = scope:exile_destination
				}
				every_in_list = {
					list = defectors
					limit = {
						OR = {
							is_child_of = scope:rowdy_boy
							is_spouse_of = scope:rowdy_boy
						}
					}
					move_to_pool_at = scope:exile_destination
				}
			}
			scope:rowdy_boy = {
				if = {
					limit = {
						can_start_scheme = {
							type = murder
							target_character = root
						}
					}
					random_list = {
						1 = {
						}
						2 = {
							modifier = {
								has_relation_rival = root
								factor = 5
							}
							start_scheme = {
								type = murder
								target_character = root
							}
						}
					}
				}
			}
		}
		stress_impact = {
			forgiving = major_stress_impact_gain
			generous = major_stress_impact_gain
			compassionate = medium_stress_impact_gain
			trusting = minor_stress_impact_gain
		}
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_compassion = -1
				ai_vengefulness = 1
			}
			modifier = {
				opinion = {
					target = scope:rowdy_boy
					value >= 80
				}
				add = -50
			}
			modifier = {
				opinion = {
					target = scope:rowdy_boy
					value < 0
				}
				add = -25
			}
			modifier = {
				opinion = {
					target = scope:rowdy_boy
					value < -50
				}
				add = 50
			}
			modifier = {
				opinion = {
					target = scope:rowdy_boy
					value < -75
				}
				add = 100
			}
			modifier = {
				OR = {
					has_trait = forgiving
					has_trait = generous
					has_trait = compassionate
					has_trait = trusting
				}
				factor = 0
			}
		}
	}
}

mpo_nomad_events.1021 = {
	hidden = yes
	immediate = {
		if = {
			limit = {
				scope:sc_attacker = {
					is_alive = yes
				}
			}
			scope:sc_attacker = {
				remove_character_flag = single_combat_stripped_to_waist
			}
		}
		if = {
			limit = {
				scope:sc_defender = {
					is_alive = yes
				}
			}
			scope:sc_defender = {
				remove_character_flag = single_combat_stripped_to_waist
			}
		}
		
		
		if = {
			limit = {
				this = scope:sc_attacker
			}
			trigger_event = mpo_nomad_events.1022
		}
	}
}

mpo_nomad_events.1022 = {
	type = character_event
	window = duel_event
	title = mpo_nomad_events.1022.t
	desc = mpo_nomad_events.1022.desc
	theme = death
	left_portrait = {
		character = root
		animation = war_over_win
	}
	right_portrait = {
		character = scope:rowdy_boy
	}
	override_background = {
		reference = terrain_scope
	}

	immediate = {
		remove_character_flag = duelling_defecting_family_flag
	}

	option = {
		name = mpo_nomad_events.1022.a
		if = {
			limit = {
				scope:rowdy_boy = {
					prowess < high_skill_rating
				}
			}
			add_prestige = medium_prestige_gain
			add_dread = medium_dread_gain
		}
		else = {
			add_prestige = major_prestige_gain
			add_dread = major_dread_gain
		}
		add_prowess_skill = 1
		
		add_character_modifier = {
			modifier = mpo_quelled_family_dissent_modifier
			years = 10
		}
		stress_impact = {
			base = minor_stress_impact_gain
			compassionate = minor_stress_impact_gain
			forgiving = minor_stress_impact_gain
		}
	}
}

scripted_trigger mpo_nomad_events_1030_child_trigger = {
	is_available = yes
	age < 16
	age >= 3
	can_be_combatant_based_on_gender_trigger = { ARMY_OWNER = root }
	NOT = {
		has_character_flag = had_mpo_nomad_events_1030
	}
	is_courtier_of = root
	is_hostage = no
}

#Which manly art do you want your son to practice?
mpo_nomad_events.1030 = {
	type = character_event
	title = mpo_nomad_events.1030.t
	desc = {
		desc = mpo_nomad_events.1030.desc
		first_valid = {
			triggered_desc = {
				trigger = {
					culture = {
						has_cultural_pillar = language_mongolic
					}
				}
				desc = mpo_nomad_events.1030.desc_mongolic
			}
			desc = mpo_nomad_events.1030.desc_non_mongolic
		}
		desc = mpo_nomad_events.1030.desc.outro
	} 
	theme = nomads
	override_background = {
		reference = courtyard
	}
	left_portrait = {
		character = root
		animation = hunting_shortbow_rest_arrow_default
		camera = camera_event_left_forward
	}
	right_portrait = {
		character = scope:child
		animation = clutching_ball
	}

	trigger = {
		has_mpo_dlc_trigger = yes
		government_has_flag = government_is_nomadic
		is_available = yes
		any_child = {
			mpo_nomad_events_1030_child_trigger = yes
		}
	}

	cooldown = {
		years = 3
	}

	immediate = {
		save_scope_as = root_scope
		add_character_flag = need_military_outfit
		#Choose primary_heir if possible
		if = {
			limit = {
				any_child = {
					is_primary_heir_of = root
					mpo_nomad_events_1030_child_trigger = yes
				}
			}
			random_child = {
				limit = {
					is_primary_heir_of = root
					mpo_nomad_events_1030_child_trigger = yes
				}
				save_scope_as = child
			}
		}
		if = {
			limit = {
				NOT = {
					exists = scope:child
				}
			}
			random_child = {
				limit = {
					mpo_nomad_events_1030_child_trigger = yes
				}
				save_scope_as = child
			}
		}
		
		scope:child = {
			add_character_flag = {
				flag = had_mpo_nomad_events_1030
				years = 15
			}
		}
	}

	weight_multiplier = {
		base = 1
		modifier = {
			any_child = {
				is_primary_heir_of = root
				mpo_nomad_events_1030_child_trigger = yes
			}
			add = 2
		}
	}

	#Him? I need practice!
	option = {
		name = mpo_nomad_events.1030.a
		flavor = mpo_nomad_events.1030.a.flavor
		trigger = {
			OR = {
				has_trait = tourney_participant
				has_trait = lifestyle_blademaster
				has_trait = education_martial_prowess_1
				has_trait = education_martial_prowess_2
				has_trait = education_martial_prowess_3
				has_trait = education_martial_prowess_4
				has_trait = berserker
				has_trait = shieldmaiden
				has_trait = gallant
				has_trait = athletic
				has_trait = impatient
				has_trait = arrogant
				has_trait = ambitious
				has_trait = diligent
			}
		}
		#Not specialized
		if = {	
			limit = {
				OR = {
					NOT = {
						has_trait = tourney_participant
					}
					NOR = {
						has_trait_xp = {
							trait = tourney_participant
							track = foot
							value >= 30
						}
						has_trait_xp = {
							trait = tourney_participant
							track = horse
							value >= 30
						}
						has_trait_xp = {
							trait = tourney_participant
							track = bow
							value >= 30
						}
					}
					AND = {
						has_trait_xp = {
							trait = tourney_participant
							track = foot
							value >= 30
						}
						has_trait_xp = {
							trait = tourney_participant
							track = horse
							value >= 30
						}
						has_trait_xp = {
							trait = tourney_participant
							track = bow
							value >= 30
						}
					}
				}
			}
			if = {	
				limit = {
					NOT = {
						has_trait = tourney_participant
					}
				}
				add_trait = tourney_participant
			}
			add_trait_xp = {
				trait = tourney_participant
				track = foot
				value = 10
			}
			add_trait_xp = {
				trait = tourney_participant
				track = bow
				value = 10
			}
			add_trait_xp = {
				trait = tourney_participant
				track = horse
				value = 10
			}
		}
		if = {
			limit = {
				has_trait = tourney_participant
				has_trait_xp = {
					trait = tourney_participant
					track = foot
					value >= 30
				}
			}
			add_trait_xp = {
				trait = tourney_participant
				track = foot
				value = 15
			}
		}
		if = {
			limit = {
				has_trait = tourney_participant
				has_trait_xp = {
					trait = tourney_participant
					track = horse
					value >= 30
				}
			}
			add_trait_xp = {
				trait = tourney_participant
				track = foot
				value = 15
			}
		}
		if = {
			limit = {
				has_trait = tourney_participant
				has_trait_xp = {
					trait = tourney_participant
					track = bow
					value >= 30
				}
			}
			add_trait_xp = {
				trait = tourney_participant
				track = foot
				value = 15
			}
		}

		stress_impact = {
			base = {
				add = miniscule_stress_impact_gain
				multiply = 0.5
			}
			compassionate = miniscule_stress_impact_gain
			generous = miniscule_stress_impact_gain
			humble = miniscule_stress_impact_gain
			lazy = medium_stress_impact_gain
			content = medium_stress_impact_gain
		}
		ai_chance = {
			base = 150
			ai_value_modifier = {
				ai_energy = 1
				ai_compassion = -0.5
			}
			modifier = {
				add = -100
				OR = {
					has_trait = compassionate
					has_trait = generous
				}
			}
			modifier = {
				factor = 0
				OR = {
					has_trait = lazy
					has_trait = content
				}
			}
		}
	}
	#Wrestling
	option = {
		name = mpo_nomad_events.1030.b
		scope:child = {
			if = {	
				limit = {
					NOT = {
						has_trait = tourney_participant
					}
				}
				add_trait = tourney_participant
			}
			add_trait_xp = {
				trait = tourney_participant
				track = foot
				value = 50
			}
			random = {
				chance = {
					value = 5
					if = {
						limit = {
							has_trait = rowdy
						}
						add = 5
					}
					if = {
						limit = {
							OR = {
								has_trait = wrathful
								has_trait = vengeful
								has_trait = sadistic
								has_trait = callous
								has_trait = fickle
								has_trait = brave
							}
						}
						add = 5
					}
				}
				add_trait = strong
			}
		}
		stress_impact = {
			craven = minor_stress_impact_gain
			paranoid = minor_stress_impact_gain
		}
		ai_chance = {
			base = 75
			ai_value_modifier = {
				ai_boldness = 0.5
			}
			modifier = {
				add = 75
				scope:child = {
					OR = {
						has_trait = wrathful
						has_trait = vengeful
						has_trait = sadistic
						has_trait = callous
						has_trait = fickle
						has_trait = brave
						has_trait = rowdy
					}
				}
			}
			modifier = {
				factor = 0
				OR = {
					has_trait = craven
					has_trait = paranoid
				}
			}
		}
	}
	#Bow
	option = {
		name = mpo_nomad_events.1030.c
		flavor = mpo_nomad_events.1030.c.flavor
		scope:child = {
			if = {	
				limit = {
					NOT = {
						has_trait = tourney_participant
					}
				}
				add_trait = tourney_participant
			}
			add_trait_xp = {
				trait = tourney_participant
				track = bow
				value = 50
			}
			random = {
				chance = {
					value = 10
					if = {
						limit = {
							has_trait = pensive
						}
						add = 10
					}
					if = {
						limit = {
							OR = {
								has_trait = patient
								has_trait = calm
								has_trait = temperate
								has_trait = chaste
								has_trait = paranoid
								has_trait = content
							}
						}
						add = 5
					}
				}
				add_trait = lifestyle_hunter
			}
		}
		stress_impact = {
			wrathful = miniscule_stress_impact_gain
			impatient = miniscule_stress_impact_gain
		}
		ai_chance = {
			base = 75
			ai_value_modifier = {
				ai_rationality = 0.5
			}
			modifier = {
				add = 75
				scope:child = {
					OR = {
						has_trait = patient
						has_trait = calm
						has_trait = temperate
						has_trait = chaste
						has_trait = paranoid
						has_trait = content
						has_trait = pensive
					}
				}
			}
			modifier = {
				add = -100
				OR = {
					has_trait = wrathful
					has_trait = impatient
				}
			}
		}
	}
	#Riding
	option = {
		name = mpo_nomad_events.1030.d
		flavor = mpo_nomad_events.1030.d.flavor
		scope:child = {
			if = {	
				limit = {
					NOT = {
						has_trait = tourney_participant
					}
				}
				add_trait = tourney_participant
			}
			add_trait_xp = {
				trait = tourney_participant
				track = horse
				value = 50
			}
			random = {
				chance = {
					value = 10
					if = {
						limit = {
							has_trait = bossy
						}
						add = 10
					}
					if = {
						limit = {
							OR = {
								has_trait = compassionate
								has_trait = trusting
								has_trait = forgiving
								has_trait = stubborn
								has_trait = diligent
								has_trait = generous
							}
						}
						add = 5
					}
				}
				add_trait = lifestyle_traveler
			}
		}
		stress_impact = {
			sadistic = miniscule_stress_impact_gain
			callous = miniscule_stress_impact_gain
		}
		ai_chance = {
			base = 50
			ai_value_modifier = {
				ai_compassion = 0.5
			}
			modifier = {
				add = 75
				scope:child = {
					OR = {
						has_trait = bossy
						has_trait = compassionate
						has_trait = trusting
						has_trait = forgiving
						has_trait = stubborn
						has_trait = diligent
						has_trait = generous
					}
				}
			}
			modifier = {
				add = -100
				OR = {
					has_trait = sadistic
					has_trait = callous
				}
			}
		}
	}

	after = {
		remove_character_flag = need_military_outfit
	}
}

#You just won an overrunning invasion war
mpo_nomad_events.1040 = {
	type = character_event
	title = mpo_nomad_events.1040.t
	desc = {
		desc = mpo_nomad_events.1040.desc
		#TRIGGERED DESC FOR GOVERNMENT TYPE GAINED
		first_valid = {
			triggered_desc = {
				trigger = {
					government_has_flag = government_is_tribal
				}
				desc = mpo_nomad_events.1040.desc_tribal
			}
			triggered_desc = {
				trigger = {
					government_has_flag = government_is_clan
				}
				desc = mpo_nomad_events.1040.desc_clan
			}
			desc = mpo_nomad_events.1040.desc_feudal
		}
	} 
	theme = war
	override_background = {
		reference = terrain_settlement
	}
	override_effect_2d = {
		reference = legend_glow	
	}
	left_portrait = {
		character = root
		animation = survey
	}
	right_portrait = {
		character = scope:warrior
		animation = horse_archer_idle
		camera = camera_event_horse_right
	}
	lower_right_portrait = scope:defender

	immediate = {
		save_scope_as = root_scope
		add_character_flag = need_military_outfit
		random_dummy_gender_soldier_effect = { SCOPE_NAME = dummy_soldier }
		#Save a warrior character just to look cool
		ordered_knight = {
			order_by = prowess
			limit = {
				is_imprisoned = no
				is_physically_able_adult = yes
				culture = root.culture
			}
			save_scope_as = warrior
		}
		if = {
			limit = {
				NOT = {
					exists = scope:warrior
				}
			}
			ordered_knight = {
				order_by = prowess
				limit = {
					is_imprisoned = no
					is_physically_able_adult = yes
				}
				save_scope_as = warrior
			}
		}
		if = {
			limit = {
				NOT = {
					exists = scope:warrior
				}
			}
			ordered_courtier = {
				order_by = prowess
				limit = {
					is_physically_able_adult = yes
					can_be_combatant_based_on_gender_trigger = { ARMY_OWNER = root }
					is_available = yes
					culture = root.culture
				}
				save_scope_as = warrior
			}
		}
		if = {
			limit = {
				NOT = {
					exists = scope:warrior
				}
			}
			ordered_courtier = {
				order_by = prowess
				limit = {
					is_physically_able_adult = yes
					can_be_combatant_based_on_gender_trigger = { ARMY_OWNER = root }
					is_available = yes
				}
				save_scope_as = warrior
			}
		}
		if = {
			limit = {
				NOT = {
					exists = scope:warrior
				}
			}
			ordered_pool_guest = {
			 	order_by = prowess
			 	limit = {
			 		is_physically_able_adult = yes
					can_be_combatant_based_on_gender_trigger = { ARMY_OWNER = root }
					is_available = yes
					culture = root.culture
			 	}
			 	save_scope_as = warrior
			}
		}
		if = {
			limit = {
				NOT = {
					exists = scope:warrior
				}
			}
			random_pool_guest = {
			 	limit = {
			 		is_physically_able_adult = yes
					can_be_combatant_based_on_gender_trigger = { ARMY_OWNER = root }
					is_available = yes
			 	}
			 	save_scope_as = warrior
			}
		}
		scope:warrior = {
			add_character_flag = need_military_outfit
		}
		#Want to mention main vassals
		ordered_vassal = {
			order_by = highest_held_title_tier
			limit = {
				highest_held_title_tier >= tier_county
				primary_title.kingdom = scope:target
			}
			save_scope_as = vassal_1
			primary_title = {
				save_scope_as = vassal_1_title
			}
		}
		if = {
			limit = {
				exists = scope:vassal_1
				any_vassal = {
					NOT = {
						this = scope:vassal_1
					}
					highest_held_title_tier >= tier_county
					primary_title.kingdom = scope:target
				}
			}
			ordered_vassal = {
				order_by = highest_held_title_tier
				limit = {
					highest_held_title_tier >= tier_county
					primary_title.kingdom = scope:target
					NOT = {
						this = scope:vassal_1
					}
				}
				save_scope_as = vassal_2
				primary_title = {
					save_scope_as = vassal_2_title
				}
			}
		}
		if = {
			limit = {
				exists = scope:vassal_2
				any_vassal = {
					NOR = {
						this = scope:vassal_1
						this = scope:vassal_2
					}
					highest_held_title_tier >= tier_county
					primary_title.kingdom = scope:target
				}
			}
			ordered_vassal = {
				order_by = highest_held_title_tier
				limit = {
					highest_held_title_tier >= tier_county
					primary_title.kingdom = scope:target
					NOR = {
						this = scope:vassal_1
						this = scope:vassal_2
					}
				}
				save_scope_as = vassal_3
				primary_title = {
					save_scope_as = vassal_3_title
				}
			}
		}
		if = {
			limit = {
				exists = scope:vassal_3
				any_vassal = {
					NOR = {
						this = scope:vassal_1
						this = scope:vassal_2
						this = scope:vassal_3
					}
					highest_held_title_tier >= tier_county
					primary_title.kingdom = scope:target
				}
			}
			ordered_vassal = {
				order_by = highest_held_title_tier
				limit = {
					highest_held_title_tier >= tier_county
					primary_title.kingdom = scope:target
					NOR = {
						this = scope:vassal_1
						this = scope:vassal_2
						this = scope:vassal_3
					}
				}
				save_scope_as = vassal_4
				primary_title = {
					save_scope_as = vassal_4_title
				}
			}
		}
		if = {
			limit = {
				exists = scope:vassal_4
				any_vassal = {
					NOR = {
						this = scope:vassal_1
						this = scope:vassal_2
						this = scope:vassal_3
						this = scope:vassal_4
					}
					highest_held_title_tier >= tier_county
					primary_title.kingdom = scope:target
				}
			}
			ordered_vassal = {
				order_by = highest_held_title_tier
				limit = {
					highest_held_title_tier >= tier_county
					primary_title.kingdom = scope:target
					NOR = {
						this = scope:vassal_1
						this = scope:vassal_2
						this = scope:vassal_3
						this = scope:vassal_4
					}
				}
				save_scope_as = vassal_5
				primary_title = {
					save_scope_as = vassal_5_title
				}
			}
		}
		capital_county = {
			save_scope_as = capital_county
		}
		primary_title = {
			save_scope_as = primary_title
		}
		custom_tooltip = overrunning_set_primary_title_tt
		custom_tooltip = overrunning_set_capital_tt
		if = {
			limit = {
				exists = scope:vassal_1
			}
			custom_tooltip = overrunning_vassal_1_tt
		}
		if = {
			limit = {
				exists = scope:vassal_2
			}
			custom_tooltip = overrunning_vassal_2_tt
		}
		if = {
			limit = {
				exists = scope:vassal_3
			}
			custom_tooltip = overrunning_vassal_3_tt
		}
		if = {
			limit = {
				exists = scope:vassal_4
			}
			custom_tooltip = overrunning_vassal_4_tt
		}

		if = {
			limit = {
				exists = scope:vassal_5
			}
			custom_tooltip = overrunning_vassal_5_tt
		}
	}
	option = {
		name = mpo_nomad_events.1040.a
	}
	after = {
		remove_character_flag = need_military_outfit
		scope:warrior = {
			remove_character_flag = need_military_outfit
		}
	}
}

scripted_trigger mpo_nomad_events_1050_herder_trigger = {
	government_has_flag = government_is_herder
	NOT = { is_tributary_of = root }
	highest_held_title_tier = tier_county
	capital_county = {
		county_fertility >= minor_county_fertility_value
	}
	NOT = {
		is_vassal_of = root
		
	}
}

#Your herds are encroaching on grazing lands of neighboring herders
mpo_nomad_events.1050 = {
	type = character_event
	title = mpo_nomad_events.1050.t
	desc = mpo_nomad_events.1050.desc
	theme = nomads
	override_background = {
		reference = mpo_camp_steppe
	}
	left_portrait = {
		character = root
		animation = dismissal
	}
	right_portrait = {
		character = scope:herder
		triggered_animation = {
			trigger = {
				root = {
					highest_held_title_tier >= tier_kingdom
				}
			}
			animation = throne_room_bow_1
		}
		triggered_animation = {
			trigger = {
				root = {
					highest_held_title_tier < tier_kingdom
				}
			}
			animation = shepherd_with_sheep
		}
		camera = camera_event_very_right
	}

	trigger = {
		age > 8
		is_available = yes
		has_mpo_dlc_trigger = yes
		government_has_flag = government_is_nomadic
		any_sub_realm_county = {
			holder = root
			county_fertility < 100
			is_landless_type_title = no
			any_neighboring_county = {
				holder = {
					mpo_nomad_events_1050_herder_trigger = yes
				}
			}
		}
	}

	cooldown = {
		years = 5
	}

	immediate = {
		random_sub_realm_county = {
			limit = {
				holder = root
				county_fertility < 100
				is_landless_type_title = no
				any_neighboring_county = {
					holder = {
						mpo_nomad_events_1050_herder_trigger = yes
					}
				}
			}
			save_scope_as = domain_county
			random_neighboring_county = {
				limit = {
					holder = {
						mpo_nomad_events_1050_herder_trigger = yes
					}
				}
				save_scope_as = herder_county
				holder = {
					save_scope_as = herder
				}
			}
		}
		every_sub_realm_county = {
			limit = {
				holder = root
				county_fertility < 100
				is_landless_type_title = no
				any_neighboring_county = {
					holder = {
						mpo_nomad_events_1050_herder_trigger = yes
					}
				}
			}
			every_neighboring_county = {
				limit = {
					holder = {
						mpo_nomad_events_1050_herder_trigger = yes
					}
				}
				holder = {
					add_to_list = herder_list
				}
			}
		}
	}
	#All my neighbors are weaker than me... I can do this wherever I want
	option = {
		trigger = {
			any_in_list = {
				list = herder_list
				count >= 2
			}
			OR = {
				has_trait = conqueror
				has_trait = greatest_of_khans
				is_gurkhan = yes
			}
		}
		name = mpo_nomad_events.1050.a
		add_internal_flag = special
		capital_county = {
			change_county_fertility = herder_list_county_fertility_value
		}
		every_in_list = {
			custom = custom.every_neighboring_herder
			list = herder_list
			custom_tooltip = capital_county_loses_fertility_tt
			hidden_effect = {
				capital_county = {
					change_county_fertility = medium_county_fertility_loss
				}
			}
		}
		if = {
			limit = {
				any_in_list = {
					list = herder_list
					count >= 4
				}
			}
			if = {
				limit = {
					highest_held_title_tier >= tier_kingdom
				}
				add_tyranny = minor_tyranny_gain
			}
			else = {
				add_piety = medium_piety_loss
			}
		}
		else = {
			add_piety = minor_piety_loss
		}
		stress_impact = {
			greedy = miniscule_stress_impact_loss
			compassionate = medium_stress_impact_gain
			generous = medium_stress_impact_gain
			just = medium_stress_impact_gain
		}
		ai_chance = {
			base = 300
			ai_value_modifier = {
				ai_honor = -1
				ai_compassion = -1
			}
			modifier = {
				factor = 0
				OR = {
					has_trait = compassionate
					has_trait = generous
					has_trait = just
				}
			}
		}
	}
	#It showed courage to stand up for yourself. Become my honored vassal
	option = {
		trigger = {
			highest_held_title_tier >= tier_duchy
			domicile = {
				herd > medium_herd_value
			}
			scope:herder = {
				is_independent_ruler = yes
				is_at_war = no
				OR = {
					AND = {
						root = {
							faith_dominant_gender_male_or_equal = yes
						}
						is_male = yes
					}
					AND = {
						root = {
							faith_dominant_gender_female_or_equal = yes
						}
						is_female = yes
					}
				}
				NOR = {
					has_trait = deceitful
					has_trait = craven
				}
			}
			OR = {
				piety_level >= high_piety_level
				has_trait = loyal
				has_trait = just
				has_trait = honest
				has_trait = compassionate
				has_trait = trusting
				has_trait = forgiving
				has_trait = generous
			}
		}
		name = mpo_nomad_events.1050.b
		flavor = mpo_nomad_events.1050.b.flavor

		scope:herder = {
			create_title_and_vassal_change = {
				type = granted
				save_scope_as = change
				add_claim_on_loss = no
			}
			change_liege = {
				liege = root
				change = scope:change
			}
			resolve_title_and_vassal_change = scope:change
			add_prestige = medium_prestige_gain
			add_opinion = {
				modifier = grateful_opinion
				target = root
				opinion = 80
			}
			save_scope_as = holder
			hidden_effect = {
				every_held_title = {
					limit = {
						tier = tier_county
					}
					if = {
						limit = {
							title_province = {
								has_holding_type = herder_holding
							}
						}
						title_province = {
							set_holding_type = nomad_holding
						}
					}
				}
			}
			change_government = nomad_government
			domicile = {
				change_herd = medium_herd_gain
			}
		}
		pay_herd = {
			target = scope:herder
			value = domicile.medium_herd_value
		}
		
		stress_impact = {
			generous = minor_stress_impact_loss
			arrogant = minor_stress_impact_gain
			paranoid = minor_stress_impact_gain
			greedy = minor_stress_impact_gain
			vengeful = medium_stress_impact_gain
		}
		ai_chance = {
			base = 50
			ai_value_modifier = {
				ai_honor = 1
				ai_energy = 0.5
				ai_compassion = 0.5
			}
			modifier = {
				factor = 0
				OR = {
					has_trait = greedy
					has_trait = arrogant
					has_trait = paranoid
					has_trait = vengeful
				}
			}
		}
	}
	#I will not be respected if I do not respect the rights of others
	option = {
		name = mpo_nomad_events.1050.c
		flavor = mpo_nomad_events.1050.c.flavor
		add_piety = medium_piety_gain
		add_prestige = minor_prestige_gain
		domicile = {
			change_herd = minor_herd_loss
		}
		stress_impact = {
			greedy = minor_stress_impact_gain
			arbitrary = medium_stress_impact_gain
		}
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_honor = 1
				ai_compassion = 1
			}
			modifier = {
				factor = 0
				OR = {
					has_trait = greedy
					has_trait = arbitrary
				}
			}
		}
	}
	#I am stronger. My animals go where they like
	option = {
		name = mpo_nomad_events.1050.d
		scope:domain_county = {
			change_county_fertility = medium_county_fertility_gain
		}
		custom_tooltip = herder_county_loses_fertility_tt
		hidden_effect = {
			scope:herder.capital_county = {
				change_county_fertility = medium_county_fertility_loss
			}
		}
		stress_impact = {
			compassionate = minor_stress_impact_gain
			generous = medium_stress_impact_gain
			just = minor_stress_impact_gain
		}
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_honor = -1
				ai_compassion = -1
			}
			modifier = {
				factor = 0
				OR = {
					has_trait = compassionate
					has_trait = generous
					has_trait = just
				}
			}
		}
	}
}

#You can make money trading with neighboring non-nomads
mpo_nomad_events.1060 = {
	type = character_event
	title = mpo_nomad_events.1060.t
	desc = mpo_nomad_events.1060.desc
	theme = nomads
	override_background = {
		reference = market
	}
	left_portrait = {
		character = root
		animation = horse_archer_idle
		camera = camera_event_horse_left_forward
	}
	right_portrait = {
		character = scope:advisor
		animation = betting
	}
	lower_right_portrait = scope:neighbor.top_liege

	trigger = {
		age >= 12
		is_available = yes
		has_mpo_dlc_trigger = yes
		government_has_flag = government_is_nomadic
		any_sub_realm_county = {
			holder = root
			any_neighboring_county = {
				any_county_province = {
					OR = {
						has_holding_type = castle_holding
						has_holding_type = city_holding
					}
				}
				holder = {
					is_ai = yes
					NOT = {
						is_at_war_with = root
					}
				}
				holder.liege ?= {
					NOT = {
						is_at_war_with = root
					}
				}
				holder.top_liege = {
					NOT = {
						is_at_war_with = root
					}
				}
			}
		}
		highest_held_title_tier < tier_kingdom
	}

	cooldown = {
		years = 10
	}

	immediate = {
		random_sub_realm_county = {
			limit = {
				holder = root
				any_neighboring_county = {
					any_county_province = {
						OR = {
							has_holding_type = castle_holding
							has_holding_type = city_holding
						}
					}
					holder = {
						is_ai = yes
						NOT = {
							is_at_war_with = root
						}
					}
					holder.liege ?= {
						NOT = {
							is_at_war_with = root
						}
					}
					holder.top_liege = {
						NOT = {
							is_at_war_with = root
						}
					}
				}
			}
			random_neighboring_county = {
				limit = {
					any_county_province = {
						OR = {
							has_holding_type = castle_holding
							has_holding_type = city_holding
						}
					}
					holder.liege ?= {
						NOT = {
							is_at_war_with = root
						}
					}
					holder = {
						is_ai = yes
						NOT = {
							is_at_war_with = root
						}
					}
					holder.top_liege = {
						NOT = {
							is_at_war_with = root
						}
					}
				}
				save_scope_as = neighbor_county
				holder = { save_scope_as = neighbor }
				culture = {
					save_scope_as = county_culture
				}
				random_county_province = {
					limit = {
						OR = {
							has_holding_type = castle_holding
							has_holding_type = city_holding
						}
					}
					save_scope_as = neighbor_province
				}

			}
		}
		scope:neighbor = {
			save_scope_as = bg_override_char
		}
		random_councillor = {
			limit = {
				is_landed = no
				is_available_ai_adult = yes
				NOT = {
					has_council_position = councillor_court_chaplain
				}
			}
			save_scope_as = advisor
		}
		if = {
			limit = {
				NOT = {
					exists = scope:advisor
				}
			}
			random_knight = {
				limit = {
					is_available_ai_adult = yes
					is_landed = no
				}
				save_scope_as = advisor
			}
		}
		if = {
			limit = {
				NOT = {
					exists = scope:advisor
				}
			}
			random_courtier = {
				limit = {
					is_available_ai_adult = yes
				}
				save_scope_as = advisor
			}
		}
		if = {
			limit = {
				NOT = {
					exists = scope:advisor
				}
			}
			random_pool_guest = {
				limit = {
					is_available_ai_adult = yes
				}
				save_scope_as = advisor
			}
		}
	}
	#High stewardship option
	option = {
		trigger = {
			stewardship >= very_high_skill_rating
		}
		name = mpo_nomad_events.1060.a
		flavor = mpo_nomad_events.1060.a.flavor
		add_character_modifier = {
			modifier = nomad_trading_mastery_modifier
			years = 10
		}
		add_gold = medium_gold_value
		domicile = {
			change_herd = miniscule_herd_loss
		}
		stress_impact = {
			greedy = miniscule_stress_impact_loss
			diligent = minor_stress_impact_loss
			ambitious = miniscule_stress_impact_loss
		}
		ai_chance = {
			base = 400
			ai_value_modifier = {
				ai_energy = -0.5
				ai_boldness = -0.5
				ai_rationality = 1
			}
		}
	}
	#No trade, only raid!
	option = {
		name = mpo_nomad_events.1060.b
		flavor = mpo_nomad_events.1060.b.flavor
		duel = {
			skill = prowess
			value = medium_skill_rating
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = -49
				}
				desc = mpo_nomad_events.1060.b.success
				send_interface_toast = {
					type = event_toast_effect_good
					title = mpo_nomad_events.1060.b.success
					left_icon = scope:neighbor
					add_gold = major_gold_value
					scope:neighbor_county = {
						change_development_progress_with_overflow =  medium_development_progress_loss
					}
				}
			}
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = -49
				}
				desc = mpo_nomad_events.1060.b.failure
				send_interface_toast = {
					type = event_toast_effect_bad
					title = mpo_nomad_events.1060.b.failure
					left_icon = scope:neighbor
					increase_wounds_effect = { REASON = fight }
				}
			}
		}
		scope:neighbor.top_liege = {
			add_opinion = {
				target = root
				modifier = angry_opinion
				opinion = -30
			}
		}
		stress_impact = {
			impatient = miniscule_stress_impact_loss
			craven = medium_stress_impact_gain
			calm = minor_stress_impact_gain
			patient = minor_stress_impact_gain
			content = miniscule_stress_impact_gain
		}
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_energy = 0.5
				ai_boldness = 1
				ai_rationality = -0.5
			}
			modifier = {
				factor = 0
				OR = {
					has_trait = craven
					has_trait = calm
					has_trait = patient
				}
			}
		}
	}
	#We've got goods to sell
	option = {
		name = mpo_nomad_events.1060.c
		flavor = mpo_nomad_events.1060.c.flavor
		add_character_modifier = {
			modifier = nomad_trading_partners_modifier
			years = 10
		}
		add_gold = medium_gold_value
		domicile = {
			change_herd = minor_herd_loss
		}
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_energy = -0.5
				ai_boldness = -0.5
				ai_rationality = 1
			}
		}
	}
}

#You wake up with only your horse
mpo_nomad_events.1070 = {
	type = character_event
	title = mpo_nomad_events.1070.t
	desc = {
		desc = mpo_nomad_events.1070.desc_intro
		first_valid = {
			triggered_desc = {
				trigger = {
					any_owned_story = {
						story_type = story_cycle_martial_lifestyle_warhorse
						exists = var:story_cycle_horse_name
					}
				}
				desc = mpo_nomad_events.1070.desc_has_horse
			}
			desc = mpo_nomad_events.1070.desc_new_horse
		}
		desc = mpo_nomad_events.1070.desc
		first_valid = {
			triggered_desc = {
				trigger = {
					has_trait = lifestyle_mystic
				}
				desc = mpo_nomad_events.1070.desc_spiritual
			}
			triggered_desc = {
				trigger = {
					OR = {
						has_trait = eccentric
						has_trait = lunatic
						has_trait = possessed
					}
				}
				desc = mpo_nomad_events.1070.desc_mental_thing
			}
			desc = mpo_nomad_events.1070.desc_new_drunk
		}
	}
	theme = nomads
	override_background = {
		reference = wilderness
	}
	left_portrait = {
		character = root
		animation = jockey_idle
		camera = camera_event_horse_extreme_closeup_left
		hide_info = yes
	}

	trigger = {
		age >= 12
		is_available = yes
		has_mpo_dlc_trigger = yes
		government_has_flag = government_is_nomadic
		highest_held_title_tier < tier_empire
		OR = {
			#Is young and foolish
			age <= 25
			#Is a mess
			has_trait = drunkard
			has_trait = lifestyle_reveler
			has_trait = hashishiyah
			#Is a little mentally off
			has_trait = eccentric
			has_trait = lunatic
			has_trait = possessed
			has_trait = lifestyle_mystic
		}
		NOT = {
			has_trait = temperate
		}
	}

	weight_multiplier = {
		base = 1
		modifier = {
			add = 3
			OR = {
				has_trait = drunkard
				has_trait = lifestyle_reveler
				has_trait = hashishiyah
				has_trait = lunatic
				has_trait = possessed
			}
		}
		modifier = {
			add = 0.5
			OR = {
				ai_energy >= medium_positive_ai_value
				ai_rationality >= medium_positive_ai_value
				ai_boldness >= medium_positive_ai_value
				ai_sociability >= medium_positive_ai_value
			}
		}
		modifier = {
			add = -0.5
			OR = {
				ai_energy <= medium_negative_ai_value
				ai_rationality <= medium_negative_ai_value
				ai_boldness <= medium_negative_ai_value
				ai_sociability <= medium_negative_ai_value
			}
		}
		#Syncretic nomads weren't strict about rules like those forbidding alcohol, but still should be accounted for
		modifier = {
			factor = -0.5
			faith_forbids_alcohol_trigger = no
		}
	}

	cooldown = {
		years = 10
	}

	immediate = {
	}

	#I love you, horse
	#Starts horse story cycle?
	option = {
		name = mpo_nomad_events.1070.a
		trigger = {
			NOR = {
				has_character_flag = had_warhorse_story
				any_owned_story = {
					story_type = story_cycle_martial_lifestyle_warhorse
					exists = var:story_cycle_horse_name
				}
			}
			NOR = {
				has_trait = sadistic
				has_trait = arbitrary
				has_trait = fickle
				has_trait = callous
			}
		}
		custom_tooltip = begin_warhorse_story_tt
		start_warhorse_story_cycle_effect = yes
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_compassion = 1
				ai_sociability = 1
			}
		}
	}

	#I must cease this horrible immature behavior...
	option = {
		trigger = {
			OR = {
				has_trait = drunkard
				has_trait = hashishiyah
			}
		}
		name = mpo_nomad_events.1070.b
		if = {
			limit = {
				has_trait = drunkard
			}
			random = {
				chance = 70
				remove_trait = drunkard
			}
		}
		else = {
			random = {
				chance = 70
				remove_trait = hashishiyah
			}
		}
		stress_impact = {
			base = minor_stress_impact_gain
			temperate = minor_stress_impact_loss
			content = medium_stress_impact_gain
			gluttonous = minor_stress_impact_gain
			fickle = minor_stress_impact_gain
		}
		ai_chance = {
			base = 200
			ai_value_modifier = {
				ai_energy = 1
				ai_rationality = 1
			}
			modifier = {
				factor = 0
				OR = {
					has_trait = content
					has_trait = gluttonous
					has_trait = fickle
					AND = {
						stress > 90
						stress < 100
					}
				}
			}
		}
	}

	#HighGod brought me here
	option = {
		trigger = {
			OR = {
				has_trait = zealous
				has_trait = lifestyle_mystic
				has_trait = devoted
			}
		}
		name = mpo_nomad_events.1070.c
		flavor = mpo_nomad_events.1070.c.flavor
		if = {
			limit = {
				NOT = {
					has_trait = lifestyle_mystic
				}
			}
			add_trait = lifestyle_mystic
		}
		else = {
			add_trait_xp = {
				trait = lifestyle_mystic
				value = small_lifestyle_random_xp_mid
			}
		}
		add_piety = minor_piety_gain
		stress_impact = {
			base = minor_stress_impact_loss
			zealous = minor_stress_impact_loss
			cynical = medium_stress_impact_gain
		}
		ai_chance = {
			base = 200
			ai_value_modifier = {
				ai_zeal = 2
			}
			modifier = {
				factor = 0
				has_trait = cynical
			}
		}
	}

	#I can find my way home
	option = {
		name = mpo_nomad_events.1070.d
		flavor = mpo_nomad_events.1070.d.flavor
		duel = {
			skills = { learning prowess }
			value = medium_skill_rating
			# You find your way back easily
			55 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					# Always give _some_ chance.
					min = -49
				}
				desc = mpo_nomad_events.1070.d.success
				send_interface_toast = {
					type = event_toast_effect_good
					title = mpo_nomad_events.1070.d.success
					left_icon = root
					if = {
						limit = {
							NOT = {
								has_trait = lifestyle_traveler
							}
						}
						add_trait = lifestyle_traveler
					}
					else = {
						add_trait_xp = {
							trait = lifestyle_traveler
							track = danger
							value = 15
						}
					}
				}
			}
			# You get horribly lost over multiple days
			45 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					# Limit how low the off-chance can go.
					min = -49
				}
				desc = mpo_nomad_events.1070.d.failure
				send_interface_toast = {
					type = event_toast_effect_bad
					title = mpo_nomad_events.1070.d.failure
					left_icon = root
					if = {
						limit = { 
							NOT = { has_trait = ill } 
						}
						show_as_tooltip = { add_trait = ill }
						hidden_effect = {
							contract_disease_effect = {
								DISEASE = ill
								TREATMENT_EVENT = no
							}
						}
					}
					else_if = {
						limit = {
							NOT = { has_trait = pneumonic }
						}
						random = {
							chance = {
								value = 40
								add = {
									value = health
									multiply = -1.5
								}
							}
							show_as_tooltip = { add_trait = pneumonic }
							hidden_effect = {
								contract_disease_effect = {
									DISEASE = pneumonic
									TREATMENT_EVENT = no
								}
							}	
						}
					}
				}
			}
		}
		stress_impact = {
			humble = minor_stress_impact_gain
			lazy = minor_stress_impact_gain
			trusting = minor_stress_impact_gain
		}
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_energy = 1
				ai_boldness = 1
			}
			modifier = {
				factor = 0.5
				OR = {
					has_trait = humble
					has_trait = lazy
					has_trait = trusting
					prowess < average_skill_rating
					learning < average_skill_rating
					AND = {
						prowess <= decent_skill_rating
						learning <= decent_skill_rating
					}
				}
			}
			modifier = {
				factor = 0
				OR = {
					has_trait = humble
					has_trait = lazy
					has_trait = trusting
					prowess < low_skill_rating
					learning < low_skill_rating
					AND = {
						prowess < average_skill_rating
						learning < average_skill_rating
					}
				}
			}
		}
	}

	#Horse can always be relied on to get me home
	option = {
		name = mpo_nomad_events.1070.e
		
		add_character_modifier = {
			modifier = nomad_alone_in_adversity_modifier
			years = 5
		}
		stress_impact = {
			cynical = minor_stress_impact_gain
			arrogant = minor_stress_impact_gain
			paranoid = minor_stress_impact_gain
			impatient = minor_stress_impact_gain
		}
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_energy = -1
				ai_compassion = 1
			}
			modifier = {
				factor = 0
				OR = {
					has_trait = cynical
					has_trait = arrogant
					has_trait = paranoid
					has_trait = impatient
				}
			}
		}
	}
}

scripted_trigger mpo_nomad_events_1080_neighbor_trigger = {
	age >= 12
	government_has_flag = government_is_nomadic
	NOR = {
		this = root
		is_vassal_or_below_of = root
		root = {
			is_vassal_or_below_of = prev
		}
	}
	is_available_ai_adult = yes
	is_travelling = no
	NOR = {
		exists = involved_activity
		is_at_war_with = root
		AND = {
			is_causing_raid_hostility_towards = root
			has_raised_armies = yes
		}
	}
	highest_held_title_tier <= tier_duchy
	exists = capital_county
	NOT = {
		has_character_flag = had_mpo_nomad_events_1080
	}
}

#You meet a neighbor's search party in your lands
mpo_nomad_events.1080 = {
	type = character_event
	title = mpo_nomad_events.1080.t
	desc = {
		first_valid = {
			triggered_desc = {
				trigger = {
					highest_held_title_tier > scope:neighbor_ruler.highest_held_title_tier
				}
				desc = mpo_nomad_events.1080.desc_high_intro
			}
			desc = mpo_nomad_events.1080.desc_low_intro
		}
		desc = mpo_nomad_events.1080.desc_1
		first_valid = {
			triggered_desc = {
				trigger = {
					scope:escaped_warrior = {
						has_trait = murderer
					}
				}
				desc = crime_murderer
			}
			triggered_desc = {
				trigger = {
					scope:escaped_warrior = {
						has_trait = witch
					}
				}
				desc = crime_witch
			}
			triggered_desc = {
				trigger = {
					scope:escaped_warrior = {
						has_trait = cannibal
					}
				}
				desc = crime_cannibal
			}
			triggered_desc = {
				trigger = {
					scope:escaped_warrior = {
						OR = {
							has_trait = deviant
							has_trait = incestuous
						}
					}
				}
				desc = crime_deviant
			}
			triggered_desc = {
				trigger = {
					scope:escaped_warrior = {
						OR = {
							has_trait = kinslayer_1
							has_trait = kinslayer_2
							has_trait = kinslayer_3
						}
					}
				}
				desc = crime_kinslayer
			}
			triggered_desc = {
				trigger = {
					scope:escaped_warrior = {
						has_trait = fornicator
					}
				}
				desc = crime_fornicator
			}
			triggered_desc = {
				trigger = {
					scope:escaped_warrior = {
						has_trait = adulterer
					}
				}
				desc = crime_adulterer
			}
			triggered_desc = {
				trigger = {
					scope:escaped_warrior = {
						has_trait = sodomite
					}
				}
				desc = crime_sodomite
			}
			desc = mpo_nomad_events.1080.criminal
		}
		desc = mpo_nomad_events.1080.desc_2
	}
	theme = nomads
	override_background = {
		reference = mpo_steppe_evening
	}
	left_portrait = {
		character = root
		animation = horse_archer_idle
		camera = camera_event_horse_left_forward
	}
	right_portrait = {
		character = scope:neighbor_ruler
		animation = horse_conversing_left
		camera = camera_event_horse_right
	}
	lower_right_portrait = scope:escaped_warrior

	trigger = {
		age >= 10
		is_available = yes
		has_mpo_dlc_trigger = yes
		government_has_flag = government_is_nomadic
		is_landed = yes
		capital_county = {
			NOT = {
				any_county_province = {
					OR = {
						is_raided = yes
						is_occupied = yes
					}
				}
			}
			
			any_neighboring_county = {
				holder = {
					mpo_nomad_events_1080_neighbor_trigger = yes
				}
			}
		}
	}

	cooldown = {
		years = 10
	}

	immediate = {
		add_character_flag = need_military_outfit
		capital_county = {
			random_neighboring_county = {
				limit = {
					holder = {
						mpo_nomad_events_1080_neighbor_trigger = yes
					}
				}
				save_scope_as = neighbor_county
				holder = {
					save_scope_as = neighbor_ruler
					#For female chance scripted effect
					save_scope_as = value_target
					add_character_flag = need_military_outfit
					add_character_flag = {
						flag = had_mpo_nomad_events_1080
						years = 10
					}
					
				}
			}
		}
		create_character = {
			template = new_warrior_character
			dynasty = none
			location = root.location
			culture = scope:neighbor_county.culture
			faith = scope:neighbor_county.faith
			gender_female_chance = root_soldier_female_chance
			save_scope_as = escaped_warrior
		}
		scope:escaped_warrior = {
			random_list = {
				1 = {
					trigger = {
						trait_is_criminal_in_faith_trigger = { TRAIT = witch FAITH = scope:neighbor_ruler.faith GENDER_CHARACTER = scope:escaped_warrior }
					}
					add_trait = witch
				}
				1 = {
					add_trait = cannibal
				}
				1 = {
					trigger = {
						trait_is_criminal_in_faith_trigger = { TRAIT = incestuous FAITH = scope:neighbor_ruler.faith GENDER_CHARACTER = scope:escaped_warrior }
					}
					add_trait = incestuous
				}
				1 = {
					trigger = {
						trait_is_criminal_in_faith_trigger = { TRAIT = kinslayer_1 FAITH = scope:neighbor_ruler.faith GENDER_CHARACTER = scope:escaped_warrior }
					}
					add_trait = kinslayer_1
				}
				1 = {
					trigger = {
						trait_is_criminal_in_faith_trigger = { TRAIT = kinslayer_2 FAITH = scope:neighbor_ruler.faith GENDER_CHARACTER = scope:escaped_warrior }
					}
					add_trait = kinslayer_2
				}
				1 = {
					trigger = {
						trait_is_criminal_in_faith_trigger = { TRAIT = kinslayer_3 FAITH = scope:neighbor_ruler.faith GENDER_CHARACTER = scope:escaped_warrior }
					}
					add_trait = kinslayer_3
				}
				3 = {
					trigger = {
						trait_is_criminal_in_faith_trigger = { TRAIT = deviant FAITH = scope:neighbor_ruler.faith GENDER_CHARACTER = scope:escaped_warrior }
					}
					add_trait = deviant
				}
				3 = {
					trigger = {
						trait_is_criminal_in_faith_trigger = { TRAIT = fornicator FAITH = scope:neighbor_ruler.faith GENDER_CHARACTER = scope:escaped_warrior }
					}
					add_trait = fornicator
				}
				3 = {
					trigger = {
						trait_is_criminal_in_faith_trigger = { TRAIT = adulterer FAITH = scope:neighbor_ruler.faith GENDER_CHARACTER = scope:escaped_warrior }
					}
					add_trait = adulterer
				}
				3 = {
					trigger = {
						trait_is_criminal_in_faith_trigger = { TRAIT = sodomite FAITH = scope:neighbor_ruler.faith GENDER_CHARACTER = scope:escaped_warrior }
					}
					add_trait = sodomite
				}
				3 = {
					trigger = {
						has_dlc_feature = landless_playable
					}
					add_trait = gallowsbait
					add_trait_xp = {
						trait = gallowsbait
						track = bandit
						value = { 10 50 }
					}
				}
				3 = {
					trigger = {
						has_dlc_feature = landless_playable
					}
					add_trait = gallowsbait
					add_trait_xp = {
						trait = gallowsbait
						track = trickster
						value = { 10 50 }
					}
				}
				3 = {
					trigger = {
						has_dlc_feature = landless_playable
					}
					add_trait = gallowsbait
					add_trait_xp = {
						trait = gallowsbait
						track = thief
						value = { 10 50 }
					}
				}
				3 = {
					trigger = {
						has_dlc_feature = landless_playable
					}
					add_trait = gallowsbait
					add_trait_xp = {
						trait = gallowsbait
						track = marauder
						value = { 10 50 }
					}
				}
				3 = {
					add_trait = disloyal
				}
				5 = {
					add_trait = murderer
				}
			}
		}
	}

	#If he can elude you... sounds like a good man to have
	option = {
		name = mpo_nomad_events.1080.a
		flavor = mpo_nomad_events.1080.a.flavor
		trigger = {
			OR = {
				has_trait = ambitious
				has_trait = arbitrary
				has_trait = greedy
				has_trait = fickle
				has_trait = gallowsbait
				has_trait = forgiving
				has_trait = schemer
				has_trait = callous
				has_trait = sadistic
				has_trait = deceitful
				has_trait = compassionate
				has_trait = generous
			}
		}
		add_courtier = scope:escaped_warrior
		scope:escaped_warrior = {
			add_opinion = {
				target = root
				modifier = was_spared
				opinion = 50
			}
		}
		if = {
			limit = {
				scope:escaped_warrior = {	
					NOT = { is_obedient_to = root }
				}
			}
			scope:escaped_warrior = {
				add_opinion = {
					modifier = obedience_opinion
					target = root
				}
			}
		}
		consume_all_criminal_reasons_effect = {
			LIEGE = root
			CRIMINAL = scope:escaped_warrior
		}
		scope:neighbor_ruler = {
			add_opinion = {
				target = root
				modifier = angry_opinion
				opinion = -20
			}
		}
		stress_impact = {
			just = major_stress_impact_gain
			zealous = minor_stress_impact_gain
			vengeful = minor_stress_impact_gain
			paranoid = medium_stress_impact_gain
		}
		ai_chance = {
			ai_value_modifier = {
				ai_honor = -1
				ai_vengefulness = -0.5
				ai_zeal = -0.5
			}
			modifier = {
				factor = 0
				OR = {
					has_trait = just
					has_trait = zealous
					has_trait = vengeful
					has_trait = paranoid
				}
			}
		}
	}
	#Chase off these unwelcome guests in a hail of arrows
	option = {
		name = mpo_nomad_events.1080.b
		flavor = mpo_nomad_events.1080.b.flavor
		
		#Your knights gain bow skill
		if = {
			limit = {
				has_dlc_feature = tours_and_tournaments
			}
			if = {
				limit = {
					can_be_combatant_based_on_gender_trigger = { ARMY_OWNER = root }
				}
				if = {
					limit = {
						NOT = {
							has_trait = tourney_participant
						}
					}
					add_trait = tourney_participant
				}
				add_trait_xp = {
					trait = tourney_participant
					track = bow
					value = tournament_hastiludes_xp_gain_medium_value
				}
			}
			every_knight = {
				custom = custom.every_knight
				if = {
					limit = {
						NOT = {
							has_trait = tourney_participant
						}
					}
					hidden_effect = {
						add_trait = tourney_participant
					}
				}
				add_trait_xp = {
					trait = tourney_participant
					track = bow
					value = tournament_hastiludes_xp_gain_medium_value
				}
			}
		}
		else = {
			add_martial_lifestyle_xp = minor_lifestyle_xp
			add_dread = minor_dread_gain
		}
		scope:neighbor_ruler = {
			progress_towards_rival_effect = {
				REASON = rival_chased_off_with_arrows
				CHARACTER = root
				OPINION = -30
			}
		}
		random = {
			chance = {
				value = 50
				if = {
					limit = {
						martial >= medium_skill_rating
					}
					add = 5
				}
				if = {
					limit = {
						prowess >= medium_skill_rating
					}
					add = 5
				}
				if = {
					limit = {
						martial >= high_skill_rating
					}
					add = 5
				}
				if = {
					limit = {
						prowess >= high_skill_rating
					}
					add = 5
				}
				if = {
					limit = {
						martial > extremely_high_skill_rating
					}
					add = 5
				}
				if = {
					limit = {
						prowess > extremely_high_skill_rating
					}
					add = 5
				}
				if = {
					limit = {
						number_of_knights >= 10
						
					}
					add = 10
				}
				if = {
					limit = {
						number_of_knights >= 14
					}
					add = 10
				}
				if = {
					limit = {
						scope:neighbor_ruler = {
							martial >= medium_skill_rating
						}
					}
					add = -5
				}
				if = {
					limit = {
						scope:neighbor_ruler = {
							prowess >= medium_skill_rating
						}
					}
					add = -5
				}
				if = {
					limit = {
						scope:neighbor_ruler = {
							martial >= high_skill_rating
						}
					}
					add = -5
				}
				if = {
					limit = {
						scope:neighbor_ruler = {
							prowess >= high_skill_rating
						}
					}
					add = -5
				}
				if = {
					limit = {
						scope:neighbor_ruler = {
							martial > extremely_high_skill_rating
						}
					}
					add = -5
				}
				if = {
					limit = {
						scope:neighbor_ruler = {
							prowess > extremely_high_skill_rating
						}
					}
					add = -5
				}
				if = {
					limit = {
						scope:neighbor_ruler = {
							number_of_knights >= 10
						}

					}
					add = -10
				}
				if = {
					limit = {
						scope:neighbor_ruler = {
							number_of_knights >= 14
						}
					}
					add = -10
				}
			}
			scope:neighbor_ruler = {
				increase_wounds_effect = { REASON = fight }
			}
		}
		stress_impact = {
			trusting = medium_stress_impact_gain
			humble = minor_stress_impact_gain
			compassionate = minor_stress_impact_gain
		}
		ai_chance = {
			base = 150
			ai_value_modifier = {
				ai_sociability = -0.5
				ai_honor = 0.5
				ai_boldness = -0.5
				ai_compassion = -0.5
			}
			modifier = {
				factor = 0
				OR = {
					has_trait = trusting
					has_trait = humble
					has_trait = compassionate
				}
			}
		}
	}
	#We will ride the fugitive down for you
	option = {
		name = mpo_nomad_events.1080.c
		
		#Your knights gain horse skill
		if = {
			limit = {
				has_dlc_feature = tours_and_tournaments
			}
			if = {
				limit = {
					can_be_combatant_based_on_gender_trigger = { ARMY_OWNER = root }
				}
				if = {
					limit = {
						NOT = {
							has_trait = tourney_participant
						}
					}
					add_trait = tourney_participant
				}
				add_trait_xp = {
					trait = tourney_participant
					track = horse
					value = tournament_hastiludes_xp_gain_medium_value
				}
			}
			every_knight = {
				custom = custom.every_knight
				if = {
					limit = {
						NOT = {
							has_trait = tourney_participant
						}
					}
					hidden_effect = {
						add_trait = tourney_participant
					}
				}
				add_trait_xp = {
					trait = tourney_participant
					track = horse
					value = tournament_hastiludes_xp_gain_medium_value
				}
			}
		}
		else = {
			capital_county = {
				add_county_modifier = {
					modifier = ranged_and_searched_modifier
					years = 5
				}
			}
		}
		reverse_add_opinion = {
			modifier = grateful_opinion
			target = scope:neighbor_ruler
			opinion = 20
		}
		rightfully_imprison_character_less_verbose_effect = {
			TARGET = scope:escaped_warrior
			IMPRISONER = scope:neighbor_ruler
		}
		stress_impact = {
			forgiving = minor_stress_impact_gain
			arbitrary = minor_stress_impact_gain
		}
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_honor = 1
				ai_vengefulness = 1
			}
			modifier = {
				factor = 0
				OR = {
					has_trait = arbitrary
					has_trait = forgiving
				}
			}
		}
	}
	after = {
		if = {
			limit = {
				scope:escaped_warrior = {
					NOR = {
						is_courtier_of = root
						is_imprisoned_by = scope:neighbor_ruler
					}
				}
			}
			scope:escaped_warrior = {
				silent_disappearance_effect = yes
			}
		}
		scope:neighbor_ruler = {
			remove_character_flag = need_military_outfit
		}
		remove_character_flag = need_military_outfit
	}
}
#Nomadic father/brother's wife marrying event
mpo_nomad_events.1090 = {
	hidden = yes
	trigger = {
		has_mpo_dlc_trigger = yes
		mpo_valid_dead_husband_trigger = yes
	}
	immediate = {
		save_scope_as = dead_husband
		primary_spouse = {
			save_scope_as = widow
		}
		if = {
			limit = {
				primary_heir ?= {
					OR = {
						is_sibling_of = root
						is_child_of = root
					}
					mpo_valid_widow_marrier_trigger = yes
				}
			}
			primary_heir = {
				trigger_event = {
					id = mpo_nomad_events.1091
					days = 6
				}
			}
		}
		else_if = {
			limit = {
				any_sibling = {
					mpo_valid_widow_marrier_trigger = yes
				}
			}
			ordered_sibling = {
				order_by = age
				limit = {
					mpo_valid_widow_marrier_trigger = yes
				}
				trigger_event = {
					id = mpo_nomad_events.1091
					days = 6
				}
			}
		}
		else = {
			ordered_child = {
				order_by = age
				limit = {
					mpo_valid_widow_marrier_trigger = yes
				}
				trigger_event = {
					id = mpo_nomad_events.1091
					days = 6
				}
			}
		}
	}	
}

scripted_trigger mpo_nomad_events_widow_relative_trigger = {
	is_ruler = yes
	highest_held_title_tier >= tier_county
	NOR = {
		is_at_war_with = root
		is_allied_to = root
		AND = {
			exists = liege
			liege = {
				is_vassal_of = root
			}
		}
	}
	is_ai = yes
	NOT = {
		this = root
	}
}

#You marry a family widow
mpo_nomad_events.1091 = {
	type = character_event
	title = mpo_nomad_events.1091.t
	desc = {
		desc = mpo_nomad_events.1091.desc
		first_valid = {
			triggered_desc = {
				trigger = {
					allowed_more_spouses = yes
				}
				desc = mpo_nomad_events.1091.desc.marry
			}
			desc = mpo_nomad_events.1091.desc.concubine
		}
	}
	theme = nomads
	override_background = {
		reference = mpo_campfire_steppe
	}
	left_portrait = {
		character = root
		animation = standing_horse
		camera = camera_event_standing_with_horse_left
	}
	right_portrait = {
		character = scope:widow
		animation = grief
	}
	lower_right_portrait = scope:dead_husband
	lower_left_portrait = scope:widow_relative

	trigger = {
		has_mpo_dlc_trigger = yes
		government_has_flag = government_is_nomadic
		scope:widow = {
			is_married = no
			is_betrothed = no
			is_alive = yes
			is_imprisoned = no
			is_ai = yes
			is_incapable = no
			has_contagious_deadly_disease_trigger = no
			NOR = {
				has_trait = celibate
				has_trait = devoted
			}
		}
		#Is root a valid marrier still?
		OR = {
			has_trait = nomadic_philosophy
			culture = {
				has_cultural_pillar = heritage_mongolic
			}
			culture = {
				has_cultural_pillar = heritage_turkic
			}
			faith.religion = faith:tengri_pagan.religion
		}
		#Can have multiple wives or concubines
		hp_accepts_harems = yes
		is_male = yes
		is_adult = yes
		NOR = {
			has_trait = celibate
			has_trait = eunuch
			has_trait = devoted
		}
		#Has a free slot for a wife or concubine
		OR = {
			allowed_more_spouses = yes
			allowed_more_concubines = yes
		}
		#Can marry the widow
		NOT = {
			relation_with_character_is_incestuous_in_my_faith_trigger = { CHARACTER = scope:widow }
		}
		is_imprisoned = no
	}

	immediate = {
		scope:widow = {
			if = {
				limit = {
					OR = {
						any_parent = {
							mpo_nomad_events_widow_relative_trigger = yes
						}
						any_sibling = {
							mpo_nomad_events_widow_relative_trigger = yes
						}
						any_child = {
							mpo_nomad_events_widow_relative_trigger = yes
						}
					}
				}
				ordered_parent = {
					order_by = max_military_strength
					limit = {
						mpo_nomad_events_widow_relative_trigger = yes
					}
					save_scope_as = widow_relative
				}
				if = {
					limit = {
						NOT = {
							exists = scope:widow_relative
						}
					}
					ordered_child = {
						order_by = max_military_strength
						limit = {
							mpo_nomad_events_widow_relative_trigger = yes
						}
						save_scope_as = widow_relative
					}
				}
				if = {
					limit = {
						NOT = {
							exists = scope:widow_relative
						}
					}
					ordered_sibling = {
						order_by = max_military_strength
						limit = {
							mpo_nomad_events_widow_relative_trigger = yes
						}
						save_scope_as = widow_relative
					}
				}
			}
		}
	}

	#OH BABY I'VE BEEN WAITING FOR THIS
	option = {
		trigger = {
			is_attracted_to_gender_of = scope:widow
			NOT = {
				has_trait = celibate
			}
			scope:widow = {
				is_attracted_to_gender_of = root
			}
			OR = {
				has_trait = lustful
				has_trait = seducer
				is_deviant_trigger = yes
				has_relation_lover = scope:widow
				has_relation_soulmate = scope:widow
				has_relation_crush = scope:widow
				any_scheme = {
					scheme_type = courting
					scheme_target_character = scope:widow
				}
				any_scheme = {
					scheme_type = seduce
					scheme_target_character = scope:widow
				}
				AND = {
					opinion = {
						target = scope:widow
						value >= 100
					}
					reverse_opinion = {
						target = scope:widow
						value >= 100
					}
				}
				scope:widow = {
					attraction > low_positive_attraction
				}
			}
		}
		name = mpo_nomad_events.1091.a
		flavor = mpo_nomad_events.1091.a.flavor
		add_internal_flag = special
		if = {
			limit = {
				OR = {
					has_relation_soulmate = scope:widow
					has_relation_lover = scope:widow
					has_relation_best_friend = scope:widow
				}
			}
			add_stress = medium_stress_impact_loss
		}
		else_if = {
			limit = {
				has_relation_friend = scope:widow
			}
			add_stress = minor_stress_impact_loss
		}
		if = {
			limit = {
				allowed_more_spouses = yes
			}
			marry = scope:widow
			custom_tooltip = family_widow_cant_divorce_tt
			scope:widow = {
				add_opinion = {
					target = root
					modifier = romance_opinion
					opinion = 40
				}
			}
			scope:widow = {
				add_character_modifier = {
					modifier = inspired_in_wifely_duties_modifier
					years = 20
				}
			}
			if = {
				limit = {
					exists = scope:widow_relative
				}
				scope:widow_relative = {
					save_scope_as = recipient
				}
				custom_tooltip = negotiate_alliance_effect_tooltip
				create_alliance = {
					target = scope:widow_relative
					allied_through_owner = root
					allied_through_target = scope:widow
				}
			}
		}
		else = {
			make_concubine = scope:widow
			custom_tooltip = family_widow_cant_dismiss_tt
			scope:widow = {
				add_opinion = {
					target = root
					modifier = romance_opinion
					opinion = 15
				}
			}
			scope:widow = {
				add_character_modifier = {
					modifier = concubine_lavished_attention_modifier
					years = 10
				}
			}
			create_character_memory = {
				type = took_kins_widow_concubine_memory
				participants = {
					dead_husband = scope:dead_husband
					widow = scope:widow
				}
			}
			scope:widow = {
				create_character_memory = {
					type = widow_taken_concubine_memory
					participants = {
						dead_husband = scope:dead_husband
						new_husband = root
					}
				}
			}
		}
		set_variable = {
			name = family_widow_forbidden_divorce
			value = scope:widow
			years = 10
		}
		custom_tooltip = family_widow_seduce_romance_bonus_tt
		stress_impact = {
			lustful = miniscule_stress_impact_loss
			impatient = miniscule_stress_impact_loss
			chaste = major_stress_impact_gain
			calm = minor_stress_impact_gain
		}
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_sociability = 0.5
				ai_compassion = 0.5
			}
			modifier = {
				factor = 2
				OR = {
					scope:widow = {
						attraction >= medium_positive_attraction
					}
					AND = {
						opinion = {
							target = scope:widow
							value >= 100
						}
						reverse_opinion = {
							target = scope:widow
							value >= 100
						}
					}
					has_relation_soulmate = scope:widow
					has_trait = lustful
				}
			}
			modifier = {
				factor = 0.5
				OR = {
					#Widow is old, root isn't
					AND = {
						age < 40
						scope:widow = {
							age >= 40
						}
					}
					AND = {
						age < 50
						scope:widow = {
							age >= 50
						}
					}
					AND = {
						age < 25
						scope:widow = {
							age >= 30
						}
					}
				}
				NOT = {
					is_deviant_trigger = yes
				}
			}
			modifier = {
				factor = 0
				OR = {
					has_trait = chaste
					has_trait = calm
				}
			}
		}
	}

	#A prestigious and powerful connection we must keep
	option = {
		trigger = {
			exists = scope:widow_relative
			allowed_more_spouses = yes
			scope:widow_relative = {
				is_vassal_of = root
			}
		}
		name = mpo_nomad_events.1091.b
		flavor = mpo_nomad_events.1091.b.flavor

		marry = scope:widow
		custom_tooltip = family_widow_cant_divorce_tt
		if = {
			limit = {
				scope:widow_relative.highest_held_title_tier <= tier_county
			}
			add_legitimacy = minor_legitimacy_gain
		}
		else = {
			add_legitimacy = medium_legitimacy_gain
		}
		if = {
			limit = {
				exists = scope:widow_relative
			}
			scope:widow_relative = {
				save_scope_as = recipient
			}
			custom_tooltip = negotiate_alliance_effect_tooltip
			create_alliance = {
				target = scope:widow_relative
				allied_through_owner = root
				allied_through_target = scope:widow
			}
		}
		
		reverse_add_opinion = {
			modifier = loyalty_opinion
			target = scope:widow_relative
			opinion = 30
		}
		
		set_variable = {
			name = family_widow_forbidden_divorce
			value = scope:widow
			years = 10
		}

		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_honor = 0.5
				ai_greed = -0.5
			}
			modifier = {
				factor = 2
				legitimacy_level <= 1
			}
			modifier = {
				factor = 2
				legitimacy_level <= 0
			}
			modifier = {
				factor = 0.25
				scope:widow_relative = {
					NOT = { is_powerful_vassal_of = root }
				}
			}
		}
	}

	#I guess I'll take his stuff... all his stuff
	option = {
		name = mpo_nomad_events.1091.c

		if = {
			limit = {
				allowed_more_concubines = yes
			}
			make_concubine = scope:widow
			custom_tooltip = family_widow_cant_dismiss_tt
			create_character_memory = {
				type = took_kins_widow_concubine_memory
				participants = {
					dead_husband = scope:dead_husband
					widow = scope:widow
				}
			}
			scope:widow = {
				create_character_memory = {
					type = widow_taken_concubine_memory
					participants = {
						dead_husband = scope:dead_husband
						new_husband = root
					}
				}
			}
		}
		else = {
			marry = scope:widow
			custom_tooltip = family_widow_cant_divorce_tt
			if = {
				limit = {
					exists = scope:widow_relative
				}
				scope:widow_relative = {
					save_scope_as = recipient
				}
				custom_tooltip = negotiate_alliance_effect_tooltip
				create_alliance = {
					target = scope:widow_relative
					allied_through_owner = root
					allied_through_target = scope:widow
				}
			}
		}
		set_variable = {
			name = family_widow_forbidden_divorce
			value = scope:widow
			years = 10
		}
		if = {
			limit = {
				highest_held_title_tier > scope:dead_husband.highest_held_title_tier
			}
			add_gold = minor_gold_value
			domicile = {
				change_herd = minor_herd_gain
			}
		}
		else_if = {
			limit = {
				highest_held_title_tier = scope:dead_husband.highest_held_title_tier
			}
			add_gold = minor_gold_value
			domicile = {
				change_herd = medium_herd_gain
			}
		}
		else = {
			add_gold = medium_gold_value
			domicile = {
				change_herd = medium_herd_gain
			}
		}
		
		
		stress_impact = {
			generous = medium_stress_impact_gain
			humble = minor_stress_impact_gain
		}
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_greed = 1
			}
			modifier = {
				add = 50
				allowed_more_spouses = yes
			}
			modifier = {
				factor = 0
				OR = {
					has_trait = generous
					has_trait = humble
				}
			}
		}
	}
	#Our family will always cherish its women
	option = {
		name = mpo_nomad_events.1091.d
		if = {
			limit = {
				allowed_more_spouses = yes
			}
			marry = scope:widow
			custom_tooltip = family_widow_cant_divorce_tt
			if = {
				limit = {
					exists = scope:widow_relative
				}
				scope:widow_relative = {
					save_scope_as = recipient
				}
				custom_tooltip = negotiate_alliance_effect_tooltip
				create_alliance = {
					target = scope:widow_relative
					allied_through_owner = root
					allied_through_target = scope:widow
				}
			}
		}
		else = {
			make_concubine = scope:widow
			custom_tooltip = family_widow_cant_dismiss_tt
			create_character_memory = {
				type = took_kins_widow_concubine_memory
				participants = {
					dead_husband = scope:dead_husband
					widow = scope:widow
				}
			}
			scope:widow = {
				create_character_memory = {
					type = widow_taken_concubine_memory
					participants = {
						dead_husband = scope:dead_husband
						new_husband = root
					}
				}
			}
		}
		set_variable = {
			name = family_widow_forbidden_divorce
			value = scope:widow
			years = 10
		}

		if = {
			limit = {
				highest_held_title_tier > scope:dead_husband.highest_held_title_tier
			}
			if = {
				limit = {
					house ?= {
						house_head = root
					}
					allowed_more_spouses = yes
				}
				dynasty = {
					add_dynasty_prestige = minor_dynasty_prestige_gain
				}
			}
			add_prestige = minor_prestige_gain
		}
		else_if = {
			limit = {
				highest_held_title_tier = scope:dead_husband.highest_held_title_tier
			}
			if = {
				limit = {
					house ?= {
						house_head = root
					}
					allowed_more_spouses = yes
				}
				dynasty = {
					add_dynasty_prestige = minor_dynasty_prestige_gain
				}
			}
			add_prestige = medium_prestige_gain
		}
		else = {
			if = {
				limit = {
					house ?= {
						house_head = root
					}
					allowed_more_spouses = yes
				}
				dynasty = {
					add_dynasty_prestige = miniscule_dynasty_prestige_gain
				}
			}
			add_prestige = major_prestige_gain
		}
		every_close_or_extended_family_member = {
			custom = custom.every_close_or_extended_family_member
			limit = {
				NOT = {
					this = root
				}
			}
			add_opinion = {
				target = root
				modifier = trust_opinion
				opinion = 10
			}
		}
		
		stress_impact = {
			arbitrary = medium_stress_impact_gain
			fickle = minor_stress_impact_gain
		}
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_honor = 1
			}
			modifier = {
				factor = 0
				OR = {
					has_trait = arbitrary
					has_trait = fickle
				}
			}
		}
	}
	#Nah, I'm good
	option = {
		name = mpo_nomad_events.1091.e
		
		if = {
			limit = {
				scope:dead_husband.highest_held_title_tier > root.highest_held_title_tier
			}
			add_legitimacy = minor_legitimacy_loss
		}
		else_if = {
			limit = {
				scope:dead_husband.highest_held_title_tier = root.highest_held_title_tier
			}
			add_legitimacy = miniscule_legitimacy_loss
		}
		
	
		if = {
			limit = {
				allowed_more_spouses = yes
				exists = scope:widow_relative
			}
			reverse_add_opinion = {
				modifier = disrespect_opinion
				target = scope:widow_relative
				opinion = -40
			}
			scope:widow = {
				add_opinion = {
					modifier = disrespect_opinion
					target = root
					opinion = -40
				}
			}
			every_close_family_member = {
				custom = custom.every_close_family_member
				limit = {
					NOR = {
						this = root
						this = scope:widow
						this = scope:widow_relative
					}
				}
				add_opinion = {
					modifier = disrespect_opinion
					target = root
					opinion = -20
				}
			}
		}
		else = {
			if = {
				limit = {
					exists = scope:widow_relative
				}
				reverse_add_opinion = {
					modifier = disrespect_opinion
					target = scope:widow_relative
					opinion = -20
				}
			}
			scope:widow = {
				add_opinion = {
					modifier = disrespect_opinion
					target = root
					opinion = -20
				}
			}
			every_close_family_member = {
				custom = custom.every_close_family_member
				limit = {
					NOR = {
						this = root
						this = scope:widow
						AND = {
							exists = scope:widow_relative
							this = scope:widow_relative
						}
					}
				}
				add_opinion = {
					modifier = disrespect_opinion
					target = root
					opinion = -10
				}
			}
		}
		stress_impact = {
			compassionate = minor_stress_impact_gain
			generous = minor_stress_impact_gain
			just = minor_stress_impact_gain
		}
		ai_chance = {
			base = 50
			ai_value_modifier = {
				ai_honor = -1
				ai_compassion = -1
			}
			modifier = {
				add = 50
				scope:widow = {
					age >= 30
				}
			}
			modifier = {
				add = 100
				scope:widow = {
					age >= 40
				}
			}
			modifier = {
				add = 100
				scope:widow = {
					age >= 50
				}
			}
			modifier = {
				add = -25
				scope:widow = {
					age <= 25
				}
			}
			modifier = {
				add = -50
				scope:widow = {
					OR = {
						has_trait = intellect_good_3
						has_trait = intellect_good_2
						has_trait = beauty_good_3
						has_trait = beauty_good_2
						has_trait = physique_good_3
						has_trait = physique_good_2
					}
				}
			}
			modifier = {
				add = 50
				scope:widow = {
					OR = {
						has_trait = intellect_bad_1
						has_trait = intellect_bad_2
						has_trait = intellect_bad_3
						has_trait = beauty_bad_1
						has_trait = beauty_bad_2
						has_trait = beauty_bad_3
					}
				}
			}
			modifier = {
				add = 50
				scope:widow = {
					OR = {
						has_trait = intellect_bad_3
						has_trait = beauty_bad_3
					}
				}
			}

			modifier = {
				factor = 0
				OR = {
					has_trait = compassionate
					has_trait = generous
					has_trait = just
				}
			}
		}
	}
}

scripted_trigger mpo_nomad_events_1100_camel_terrain_trigger = {
	root.capital_province = {
		OR = {
			terrain = desert
			terrain = desert_mountains
			terrain = oasis
		}
	}
}

scripted_trigger mpo_nomad_events_1100_sheep_terrain_trigger = {
	root.capital_province = {
		OR = {
			terrain = mountains
			terrain = hills
			terrain = drylands
		}
	}
}

scripted_trigger mpo_nomad_events_1100_hunting_terrain_trigger = {
	root.capital_province = {
		OR = {
			terrain = forest
			terrain = taiga
			terrain = wetlands
			terrain = jungle
		}
	}
}

scripted_trigger mpo_nomad_events_1100_horse_terrain_trigger = {
	root.capital_province = {
		OR = {
			terrain = plains
			terrain = steppe
			terrain = floodplains
		}
	}
}

scripted_trigger mpo_nomad_events_1100_laborer_trigger = {
	is_available_ai_adult = yes
	is_adult = yes
	NOR = {
		is_close_family_of = root
		is_concubine_of = root
		is_spouse_of = root
		is_councillor_of = root
		any_spouse = {
			exists = root.house
			house ?= root.house
		}
	}
	is_knight = no
	is_lowborn = yes
	can_be_combatant_based_on_gender_trigger = { ARMY_OWNER = root }
}


#Local terrain is good for certain type of animal
mpo_nomad_events.1100 = {
	type = character_event
	title = mpo_nomad_events.1100.t
	desc = {
		desc = mpo_nomad_events.1100.desc
		first_valid = {
			triggered_desc = {
				trigger = {
					mpo_nomad_events_1100_camel_terrain_trigger = yes
				}
				desc = mpo_nomad_events.1100.desc.camel
			}
			triggered_desc = {
				trigger = {
					mpo_nomad_events_1100_sheep_terrain_trigger = yes
				}
				desc = mpo_nomad_events.1100.desc.sheep
			}
			triggered_desc = {
				trigger = {
					mpo_nomad_events_1100_hunting_terrain_trigger = yes
				}
				desc = mpo_nomad_events.1100.desc.hunting
			}
			desc = mpo_nomad_events.1100.desc.horses
		}
	}
	theme = nomads
	override_background = {
		reference = wilderness
	}
	left_portrait = {
		character = root
		animation = standing_horse
		camera = camera_event_standing_with_horse_left
	}
	right_portrait = {
		character = scope:laborer
		animation = survey_staff
		camera = camera_event_right_forward
	}

	trigger = {
		age >= 4
		has_mpo_dlc_trigger = yes
		government_has_flag = government_is_nomadic
		is_landed = yes
		is_available = yes
		capital_county = {
			county_fertility >= 30
			county_fertility < 100
			NOT = {
				any_county_province = {
					OR = {
						is_raided = yes
						is_occupied = yes
					}
				}
			}
		}
		OR = {
			mpo_nomad_events_1100_camel_terrain_trigger = yes
			mpo_nomad_events_1100_sheep_terrain_trigger = yes
			mpo_nomad_events_1100_hunting_terrain_trigger = yes
			mpo_nomad_events_1100_horse_terrain_trigger = yes
		}
		#Might feel weird if it's super snowy and wintery
		OR = {
			current_month < 11
			current_month > 2
		}
		is_at_war = no
	}

	cooldown = {
		years = 10
	}

	immediate = {
		capital_province = {
			save_scope_as = capital_province
		}
		random_courtier = {
			limit = {
				mpo_nomad_events_1100_laborer_trigger = yes
			}
			save_scope_as = laborer
		}
		if = {
			limit = {
				NOT = {
					exists = scope:laborer
				}
			}
			random_pool_guest = {
				limit = {
					mpo_nomad_events_1100_laborer_trigger = yes
				}
				save_scope_as = laborer
			}
		}
		if = {
			limit = {
				NOT = {
					exists = scope:laborer
				}
			}
			random_pool_character = {
				province = root.capital_province
				limit = {
					mpo_nomad_events_1100_laborer_trigger = yes
				}
				save_scope_as = laborer
			}
		}
		hidden_effect = {
			if = {
				limit = {
					highest_held_title_tier >= tier_duchy
					OR = {
						has_trait = education_stewardship_3
						has_trait = education_stewardship_4
						has_trait = education_stewardship_5
						has_trait = architect
						has_trait = administrator
						has_trait = avaricious
					}
				}
				if = {
					limit = {
						mpo_nomad_events_1100_camel_terrain_trigger = yes
					}
					every_sub_realm_county = {
						limit = {
							any_county_province = {
								OR = {
									terrain = desert
									terrain = desert_mountains
									terrain = oasis
								}
							}
						}
						add_to_list = realm_suitable_terrains
					}
				}
				if = {
					limit = {
						mpo_nomad_events_1100_sheep_terrain_trigger = yes
					}
					every_sub_realm_county = {
						limit = {
							any_county_province = {
								OR = {
									terrain = mountains
									terrain = hills
									terrain = drylands
								}
							}
						}
						add_to_list = realm_suitable_terrains
					}
				}
				if = {
					limit = {
						mpo_nomad_events_1100_hunting_terrain_trigger = yes
					}
					every_sub_realm_county = {
						limit = {
							any_county_province = {
								OR = {
									terrain = forest
									terrain = taiga
									terrain = wetlands
									terrain = jungle
								}
							}
						}
						add_to_list = realm_suitable_terrains
					}
				}
				else = {
					every_sub_realm_county = {
						limit = {
							any_county_province = {
								OR = {
									terrain = steppe
									terrain = plains
									terrain = floodplains
								}
							}
						}
						add_to_list = realm_suitable_terrains
					}
				}
				
			}
		}
	}

	#Stewardship option
	option = {
		trigger = {
			highest_held_title_tier >= tier_duchy
			OR = {
				has_trait = education_stewardship_3
				has_trait = education_stewardship_4
				has_trait = education_stewardship_5
				has_trait = architect
				has_trait = administrator
				has_trait = avaricious
			}
		}
		name = mpo_nomad_events.1100.a
		flavor = mpo_nomad_events.1100.a.flavor
		if = {
			limit = {
				mpo_nomad_events_1100_camel_terrain_trigger = yes
			}
			add_character_modifier = {
				modifier = specialized_herds_modifier_camel
				years = 10
			}
			every_in_list = {
				custom = custom.every_camel_terrain_county_tt
				list = realm_suitable_terrains
				custom_tooltip = major_county_fertility_gain_tt
				hidden_effect = {
					change_county_fertility = major_county_fertility_gain
				}
			}
		}
		else_if = {
			limit = {
				mpo_nomad_events_1100_sheep_terrain_trigger = yes
			}
			add_character_modifier = {
				modifier = specialized_herds_modifier_sheep
				years = 10
			}
			every_in_list = {
				custom = custom.every_sheep_terrain_county_tt
				list = realm_suitable_terrains
				custom_tooltip = medium_county_fertility_gain_tt
				hidden_effect = {
					change_county_fertility = medium_county_fertility_gain
				}
			}
		}
		else_if = {
			limit = {
				mpo_nomad_events_1100_hunting_terrain_trigger = yes
			}
			add_character_modifier = {
				modifier = specialized_herds_modifier_hunting
				years = 10
			}
			every_in_list = {
				custom = custom.every_hunting_terrain_county_tt
				list = realm_suitable_terrains
				custom_tooltip = medium_county_fertility_gain_tt
				hidden_effect = {
					change_county_fertility = medium_county_fertility_gain
				}
			}
		}
		else = {
			add_character_modifier = {
				modifier = specialized_herds_modifier_horses
				years = 10
			}
			every_in_list = {
				custom = custom.every_horse_terrain_county_tt
				list = realm_suitable_terrains
				custom_tooltip = medium_county_fertility_gain_tt
				hidden_effect = {
					change_county_fertility = medium_county_fertility_gain
				}
			}
		}
		add_stewardship_lifestyle_xp = medium_lifestyle_xp
		
		
		domicile = {
			change_herd = medium_herd_loss
		}
		stress_impact = {
			impatient = minor_stress_impact_gain
			lazy = minor_stress_impact_gain
		}
		ai_chance = {
			base = 200
			ai_value_modifier = {
				ai_rationality = 0.5
				ai_energy = 0.5
			}
			modifier = {
				factor = 0.5
				NOT = {
					has_lifestyle = stewardship_lifestyle
				}
			}
			#Culture matches terrain
			modifier = {
				factor = 2
				OR = {
					AND = {
						mpo_nomads_horse_culture_trigger = yes
						mpo_nomad_events_1100_horse_terrain_trigger = yes
					}
					AND = {
						mpo_nomads_hunting_culture_trigger = yes
						mpo_nomad_events_1100_hunting_terrain_trigger = yes
					}
					AND = {
						mpo_nomads_sheep_culture_trigger = yes
						mpo_nomad_events_1100_sheep_terrain_trigger = yes
					}
					AND = {
						mpo_nomads_camel_culture_trigger = yes
						mpo_nomad_events_1100_camel_terrain_trigger = yes
					}
				}
			}
			#Culture doesn't match terrain, but matches a different one
			modifier = {
				factor = 0.5
				NOR = {
					AND = {
						mpo_nomads_horse_culture_trigger = yes
						mpo_nomad_events_1100_horse_terrain_trigger = yes
					}
					AND = {
						mpo_nomads_hunting_culture_trigger = yes
						mpo_nomad_events_1100_hunting_terrain_trigger = yes
					}
					AND = {
						mpo_nomads_sheep_culture_trigger = yes
						mpo_nomad_events_1100_sheep_terrain_trigger = yes
					}
					AND = {
						mpo_nomads_camel_culture_trigger = yes
						mpo_nomad_events_1100_camel_terrain_trigger = yes
					}
				}
				OR = {
					mpo_nomads_horse_culture_trigger = yes
					mpo_nomads_camel_culture_trigger = yes
					mpo_nomads_sheep_culture_trigger = yes
					mpo_nomads_hunting_culture_trigger = yes
				}
			}
			modifier = {
				factor = 0
				OR = {
					has_trait = impatient
					has_trait = lazy
					domicile = {
						herd < massive_herd_value
					}
				}
			}
		}
	}

	#Eh I don't like it here
	option = {
		name = mpo_nomad_events.1100.b
		
		add_character_modifier = {
			modifier = mpo_restless_for_migration_modifier
			years = 2
		}
		capital_county = {
			change_county_fertility = medium_county_fertility_loss
		}

		stress_impact = {
			content = medium_stress_impact_gain
			calm = minor_stress_impact_gain
			patient = minor_stress_impact_gain
		}
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_energy = 0.5
				ai_rationality = -0.5
			}
			#Culture matches terrain
			modifier = {
				factor = 0.5
				OR = {
					AND = {
						mpo_nomads_horse_culture_trigger = yes
						mpo_nomad_events_1100_horse_terrain_trigger = yes
					}
					AND = {
						mpo_nomads_hunting_culture_trigger = yes
						mpo_nomad_events_1100_hunting_terrain_trigger = yes
					}
					AND = {
						mpo_nomads_sheep_culture_trigger = yes
						mpo_nomad_events_1100_sheep_terrain_trigger = yes
					}
					AND = {
						mpo_nomads_camel_culture_trigger = yes
						mpo_nomad_events_1100_camel_terrain_trigger = yes
					}
				}
			}
			#Culture doesn't match terrain, but matches a different one
			modifier = {
				factor = 2
				NOR = {
					AND = {
						mpo_nomads_horse_culture_trigger = yes
						mpo_nomad_events_1100_horse_terrain_trigger = yes
					}
					AND = {
						mpo_nomads_hunting_culture_trigger = yes
						mpo_nomad_events_1100_hunting_terrain_trigger = yes
					}
					AND = {
						mpo_nomads_sheep_culture_trigger = yes
						mpo_nomad_events_1100_sheep_terrain_trigger = yes
					}
					AND = {
						mpo_nomads_camel_culture_trigger = yes
						mpo_nomad_events_1100_camel_terrain_trigger = yes
					}
				}
				OR = {
					mpo_nomads_horse_culture_trigger = yes
					mpo_nomads_camel_culture_trigger = yes
					mpo_nomads_sheep_culture_trigger = yes
					mpo_nomads_hunting_culture_trigger = yes
				}
			}
			modifier = {
				factor = 0
				OR = {
					has_trait = content
					has_trait = calm
					has_trait = patient
				}
			}
		}
	}

	#We shall exploit this land to the fullest!
	option = {
		name = {
			trigger = {
				mpo_nomad_events_1100_camel_terrain_trigger = yes
			}
			text = mpo_nomad_events.1100.c.camel
		}
		name = {
			trigger = {
				mpo_nomad_events_1100_sheep_terrain_trigger = yes
			}
			text = mpo_nomad_events.1100.c.sheep
		}
		name = {
			trigger = {
				mpo_nomad_events_1100_hunting_terrain_trigger = yes
			}
			text = mpo_nomad_events.1100.c.hunting
		}
		name = {
			trigger = {
				mpo_nomad_events_1100_horse_terrain_trigger = yes
			}
			text = mpo_nomad_events.1100.c.horse
		}

		capital_county = {
			change_county_fertility = medium_county_fertility_gain
		}
		#Camels flourishing
		if = {
			limit = {
				mpo_nomad_events_1100_camel_terrain_trigger = yes
			}
			add_character_modifier = {
				modifier = mpo_bountiful_camels_modifier
				years = 10
			}
		}
		#Sheep flourishing
		else_if = {
			limit = {
				mpo_nomad_events_1100_sheep_terrain_trigger = yes
			}
			custom_tooltip = mpo_bountiful_sheep_cheaper_feasts_tt
			add_character_modifier = {
				modifier = mpo_bountiful_sheep_modifier
				years = 10
				desc = mpo_bountiful_sheep_cheaper_feasts.desc
			}
		}
		#Hunting is great
		else_if = {
			limit = {
				mpo_nomad_events_1100_hunting_terrain_trigger = yes
			}
			custom_tooltip = mpo_bountiful_hunting_cheaper_hunts_tt
			hidden_effect = {
				add_character_modifier = {
					modifier = mpo_bountiful_hunting_modifier
					years = 10
					desc = mpo_bountiful_hunting_cheaper_hunts_desc
				}
			}
			#Hunts are improved
			if = {
				limit = {
					NOT = {
						has_trait = lifestyle_hunter
					}
				}
				random = {
					chance = 60
					add_trait = lifestyle_hunter
				}
			}
			else_if = {
				limit = {
					has_trait = lifestyle_hunter
					can_be_combatant_based_on_gender_trigger = { ARMY_OWNER = root }
				}
				add_trait_xp = {
					trait = lifestyle_hunter
					value = minor_trait_xp
					track = falconer
				}
				add_trait_xp = {
					trait = lifestyle_hunter
					value = minor_trait_xp
					track = hunter
				}
			}
			else = {
				add_trait_xp = {
					trait = lifestyle_hunter
					value = medium_trait_xp
					track = falconer
				}
			}
		}
		#Horses flourishing
		else = {
			#Herd and cavalry modifier
			add_character_modifier = {
				modifier = mpo_bountiful_horses_modifier
				years = 10
			}
		}
		stress_impact = {
			stubborn = minor_stress_impact_gain
		}
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_rationality = 1
			}
			#Culture matches terrain
			modifier = {
				factor = 2
				OR = {
					AND = {
						mpo_nomads_horse_culture_trigger = yes
						mpo_nomad_events_1100_horse_terrain_trigger = yes
					}
					AND = {
						mpo_nomads_hunting_culture_trigger = yes
						mpo_nomad_events_1100_hunting_terrain_trigger = yes
					}
					AND = {
						mpo_nomads_sheep_culture_trigger = yes
						mpo_nomad_events_1100_sheep_terrain_trigger = yes
					}
					AND = {
						mpo_nomads_camel_culture_trigger = yes
						mpo_nomad_events_1100_camel_terrain_trigger = yes
					}
				}
			}
			#Culture doesn't match terrain, but matches a different one
			modifier = {
				factor = 0.5
				NOR = {
					AND = {
						mpo_nomads_horse_culture_trigger = yes
						mpo_nomad_events_1100_horse_terrain_trigger = yes
					}
					AND = {
						mpo_nomads_hunting_culture_trigger = yes
						mpo_nomad_events_1100_hunting_terrain_trigger = yes
					}
					AND = {
						mpo_nomads_sheep_culture_trigger = yes
						mpo_nomad_events_1100_sheep_terrain_trigger = yes
					}
					AND = {
						mpo_nomads_camel_culture_trigger = yes
						mpo_nomad_events_1100_camel_terrain_trigger = yes
					}
				}
				OR = {
					mpo_nomads_horse_culture_trigger = yes
					mpo_nomads_camel_culture_trigger = yes
					mpo_nomads_sheep_culture_trigger = yes
					mpo_nomads_hunting_culture_trigger = yes
				}
			}
			modifier = {
				factor = 0
				has_trait = stubborn
			}
		}
	}
}

scripted_trigger mpo_nomad_events_1110_fishing_culture_trigger = {
	culture = {
		OR = {
			has_cultural_tradition = tradition_fp1_coastal_warriors
			has_cultural_tradition = tradition_maritime_mercantilism
			has_cultural_tradition = tradition_polders
			has_cultural_tradition = tradition_wetlanders
			has_cultural_tradition = tradition_fishermen
			has_cultural_tradition = tradition_seafaring
			has_cultural_tradition = tradition_fp1_coastal_warriors
			has_cultural_tradition = tradition_practiced_pirates
		}
	}
}

scripted_trigger mpo_nomad_events_1110_char_trigger = {
	is_available_ai_adult = yes
	can_be_combatant_based_on_gender_trigger = { ARMY_OWNER = root }
}

#Your capital is next to a lake where locals fish
mpo_nomad_events.1110 = {
	type = character_event
	title = mpo_nomad_events.1110.t
	desc = {
		first_valid = {
			triggered_desc = {
				trigger = {
					root.capital_county = {
						is_riverside_county = yes
						NOR = {
							is_coastal_county = yes
							is_lakeside_county = yes
						}
					}
				}
				desc = mpo_nomad_events.1110.desc_river
			}
			triggered_desc = {
				trigger = {
					root.capital_county = {
						is_coastal_county = yes
					}
				}
				desc = mpo_nomad_events.1110.desc_sea
			}
			desc = mpo_nomad_events.1110.desc_lake
		}
		desc = mpo_nomad_events.1110.desc
	}
	theme = nomads
	override_background = {
		trigger = {
			root.capital_county = {
				OR = {
					is_coastal_county = yes
					is_lakeside_county = yes
				}
			}
		}
		reference = bp3_coast
	}
	override_background = {
		trigger = {
			root.capital_county = {
				is_riverside_county = yes
				NOR = {
					is_coastal_county = yes
					is_lakeside_county = yes
				}
			}
		}
		reference = bp3_riverside
	}
	left_portrait = {
		character = root
		triggered_animation = {
			trigger = {
				mpo_nomad_events_1110_fishing_culture_trigger = yes
			}
			animation = jockey_victory
		}
		triggered_animation = {
			trigger = {
				mpo_nomad_events_1110_fishing_culture_trigger = no
			}
			animation = horse_archer_idle
		}
		camera = camera_event_horse_left_forward
	}
	right_portrait = {
		character = scope:laborer
		animation = throne_room_cheer_2
		camera = camera_event_right_pointing_left
	}

	trigger = {
		age >= 10
		government_has_flag = government_is_nomadic
		is_landed = yes
		has_mpo_dlc_trigger = yes
		is_available = yes
		capital_county = {
			NOT = {
				any_county_province = {
					OR = {
						is_raided = yes
						is_occupied = yes
					}
				}
			}
			OR = {
				is_coastal_county = yes
				is_riverside_county = yes
				is_lakeside_county = yes
			}
		}
		#Might feel weird if it's super snowy and wintery
		OR = {
			current_month < 11
			current_month > 2
		}		
		is_at_war = no
	}

	cooldown = {
		years = 10
	}

	immediate = {
		random_dummy_gender_soldier_effect = { SCOPE_NAME = dummy_gender }
		capital_province = {
			save_scope_as = capital_province
		}
		random_courtier = {
			limit = {
				mpo_nomad_events_1110_char_trigger = yes
			}
			save_scope_as = laborer
		}
		if = {
			limit = {
				NOT = {
					exists = scope:laborer
				}
			}
			random_pool_guest = {
				limit = {
					mpo_nomad_events_1110_char_trigger = yes
				}
				save_scope_as = laborer
			}
		}
		if = {
			limit = {
				NOT = {
					exists = scope:laborer
				}
			}
			random_pool_character = {
				province = root.capital_province
				limit = {
					mpo_nomad_events_1110_char_trigger = yes
				}
				save_scope_as = laborer
			}
		}
		every_held_county = {
			limit = {
				is_landless_type_title = no
				OR = {
					is_coastal_county = yes
					is_riverside_county = yes
					is_lakeside_county = yes
				}
			}
			add_to_list = fishing_counties
		}
	}
	#Special unlock
	option = {
		trigger = {
			mpo_nomad_events_1110_fishing_culture_trigger = yes
		}
		name = {
			trigger = {
				NOT = {
					domicile = {
						has_domicile_building_or_higher = fishing_yurt_01
					}
				}
			}
			text = mpo_nomad_events.1110.a
		}
		name = {
			trigger = {
				domicile = {
					has_domicile_building_or_higher = fishing_yurt_01
				}
			}
			text = mpo_nomad_events.1110.a_repeat
		}
		add_internal_flag = special
		custom_tooltip = maritime_tradition_unlock_tt

		every_in_list = {
			custom = custom.every_fishing_county_tt
			list = fishing_counties
			custom_tooltip = major_county_fertility_gain_tt
			hidden_effect = {
				change_county_fertility = major_county_fertility_gain
			}
		}
		if = {
			limit = {
				NOR = {
					has_character_flag = nomad_unlocked_fishing_yurt_flag
					domicile = {
						has_domicile_building_or_higher = fishing_yurt_01
					}
				}
			}
			add_character_flag = nomad_unlocked_fishing_yurt_flag
			custom_tooltip = nomad_unlocked_fishing_yurt_flag_tt
		}
		else_if = {
			limit = {
				domicile = {
						has_domicile_building_or_higher = fishing_yurt_01
					}
			}
			add_gold = fishing_counties_gold_value
			custom_tooltip = fishing_counties_gold_scaling
		}

		stress_impact = {
		}
		ai_chance = {
			base = 300
			ai_value_modifier = {
				ai_energy = 0.5
			}
		}
	}

	#i'll drown the man who gets off his horse to fish
	option = {
		name = mpo_nomad_events.1110.b
		
		add_prestige = minor_prestige_gain
		domicile = {
			change_herd = minor_herd_gain
		}
		every_in_list = {
			custom = custom.every_fishing_county_tt
			list = fishing_counties
			custom_tooltip = minor_county_fertility_loss_tt
			hidden_effect = {
				change_county_fertility = minor_county_fertility_loss
			}
		}
		stress_impact = {
			stubborn = miniscule_stress_impact_loss
			calm = minor_stress_impact_gain
			humble = minor_stress_impact_gain
		}
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_rationality = -0.5
				ai_vengefulness = 0.5
			}
			modifier = {
				factor = 0
				OR = {
					has_trait = calm
					has_trait = humble
				}
			}
		}
	}
	#Cool, let's rake in the fish
	option = {
		name = mpo_nomad_events.1110.c
		add_gold = fishing_counties_gold_value
		custom_tooltip = fishing_counties_gold_scaling
		every_in_list = {
			custom = custom.every_fishing_county_tt
			list = fishing_counties
			custom_tooltip = minor_county_fertility_gain_tt
			hidden_effect = {
				change_county_fertility = minor_county_fertility_gain
			}
		}
		stress_impact = {
			stubborn = minor_stress_impact_gain
			arrogant = minor_stress_impact_gain
		}
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_rationality = 0.5
				ai_zeal = -0.5
			}
			modifier = {
				factor = 0
				OR = {
					has_trait = stubborn
					has_trait = arrogant
				}
			}
		}
	}
}

scripted_trigger mpo_nomad_events_1120_warrior_trigger = {
	is_available_ai_adult = yes
	can_be_combatant_based_on_gender_trigger = { ARMY_OWNER = root }
}

#Wolves threaten the animals
mpo_nomad_events.1120 = {
	type = character_event
	title = mpo_nomad_events.1120.t
	desc = mpo_nomad_events.1120.desc
	theme = nomads
	override_background = {
		reference = mpo_steppe_evening
	}
	left_portrait = {
		character = root
		animation = horse_sword_shield
		camera = camera_event_horse_very_left
	}
	right_portrait = {
		character = scope:warrior
		animation = jockey_gallop
		camera = camera_event_horse_right_facing_left
	}

	trigger = {
		age >= 10
		government_has_flag = government_is_nomadic
		is_landed = yes
		has_mpo_dlc_trigger = yes
		is_available = yes
		capital_county = {
			NOT = {
				any_county_province = {
					OR = {
						is_raided = yes
						is_occupied = yes
					}
				}
			}
			AND = {
				exists = root.location.county
				this = root.location.county
			}
		}
		is_at_war = no
		is_pregnant = no
		NOT = {
			has_trait = infirm
		}

		OR = {
			current_month >= 10
			current_month <= 3
		}
		location_has_harsh_winter_trigger = yes
	}

	weight_multiplier = {
		base = 1
		modifier = {
			add = 3
			any_character_situation = {
				OR = {
					any_situation_sub_region = {
					    sub_region_current_phase = situation_steppe_white_zud_season
					    situation_sub_region_has_county = root.capital_county  
					}
					any_situation_sub_region = {
					    sub_region_current_phase = situation_steppe_cold_zud_season
					    situation_sub_region_has_county = root.capital_county  
					}
				}
			}
		}
	}

	cooldown = {
		years = 10
	}

	immediate = {
		capital_province = {
			save_scope_as = capital_province
		}
		capital_county = {
			save_scope_as = capital_county
		}
		random_knight = {
			limit = {
				mpo_nomad_events_1120_warrior_trigger = yes
			}
			save_scope_as = warrior
		}
		if = {
			limit = {
				NOT = {
					exists = scope:warrior
				}
			}
			random_courtier = {
				limit = {
					mpo_nomad_events_1120_warrior_trigger = yes
				}
				save_scope_as = warrior
			}
		}
	}
	#I have more than enough riders to deal with this...
	option = {
		name = mpo_nomad_events.1120.a
		flavor = mpo_nomad_events.1120.a.flavor
		trigger = {
			OR = {
				domicile = {
					herd > monumental_herd_value_static
				}
				max_military_strength >= 4000
			}
		}
		add_internal_flag = special

		root.capital_county = {
			change_county_fertility = minor_county_fertility_gain
		}

		stress_impact = {
			humble = miniscule_stress_impact_gain
		}
		ai_chance = {
			base = 200
			ai_value_modifier = {
				ai_energy = -0.5
			}
			modifier = {
				factor = 0
				has_trait = humble
			}
		}
	}

	#Ride swiftly
	option = {
		name = mpo_nomad_events.1120.b
		
		duel = {
			skill = prowess
			value = decent_skill_rating
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = 2.5
					min = -49
				}
				modifier = {
					add = 15
					has_trait = tourney_participant
					has_trait_xp = {
						trait = tourney_participant
						value >= 10
						track = horse
					}
				}
				modifier = {
					add = 30
					has_trait = tourney_participant
					has_trait_xp = {
						trait = tourney_participant
						value >= 30
						track = horse
					}
				}
				modifier = {
					add = 15
					has_trait = tourney_participant
					has_trait_xp = {
						trait = tourney_participant
						value >= 50
						track = horse
					}
				}
				modifier = {
					add = 30
					has_trait = tourney_participant
					has_trait_xp = {
						trait = tourney_participant
						value >= 65
						track = horse
					}
				}
				modifier = {
					add = 15
					has_trait = tourney_participant
					has_trait_xp = {
						trait = tourney_participant
						value >= 85
						track = horse
					}
				}
				modifier = {
					add = 50
					has_trait = tourney_participant
					has_trait_xp = {
						trait = tourney_participant
						value >= 100
						track = horse
					}
				}
				desc = mpo_nomad_events.1120.b.success
				send_interface_toast = {
					type = event_toast_effect_good
					title = mpo_nomad_events.1120.b.success
					left_icon = root
					
					if = {
						limit = {
							has_dlc_feature = tours_and_tournaments
						}
						if = {
							limit = {
								NOT = {
									has_trait = tourney_participant
								}
							}
							add_trait = tourney_participant
						}
						add_trait_xp = {
							trait = tourney_participant
							track = horse
							value = 10
						}
					}
					add_prestige = minor_prestige_gain
				}
			}
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = -2.5
					min = -49
				}
				desc = mpo_nomad_events.1120.b.failure
				send_interface_toast = {
					type = event_toast_effect_bad
					title = mpo_nomad_events.1120.b.failure
					domicile = {
						change_herd = minor_herd_loss
					}
				}
			}
		}
		stress_impact = {
			craven = minor_stress_impact_gain
			lazy = minor_stress_impact_gain
		}
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_boldness = 0.5
				ai_energy = 0.5
			}
			modifier = {
				factor = 0
				OR = {
					has_trait = craven
					has_trait = lazy
				}
			}
		}
	}
	#Arrows! Arrows!
	option = {
		name = mpo_nomad_events.1120.c
		
		duel = {
			skill = martial
			value = decent_skill_rating
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = 2.5
					min = -49
				}
				modifier = {
					add = 15
					has_trait = tourney_participant
					has_trait_xp = {
						trait = tourney_participant
						value >= 10
						track = bow
					}
				}
				modifier = {
					add = 30
					has_trait = tourney_participant
					has_trait_xp = {
						trait = tourney_participant
						value >= 30
						track = bow
					}
				}
				modifier = {
					add = 15
					has_trait = tourney_participant
					has_trait_xp = {
						trait = tourney_participant
						value >= 50
						track = bow
					}
				}
				modifier = {
					add = 30
					has_trait = tourney_participant
					has_trait_xp = {
						trait = tourney_participant
						value >= 65
						track = bow
					}
				}
				modifier = {
					add = 15
					has_trait = tourney_participant
					has_trait_xp = {
						trait = tourney_participant
						value >= 85
						track = bow
					}
				}
				modifier = {
					add = 50
					has_trait = tourney_participant
					has_trait_xp = {
						trait = tourney_participant
						value >= 100
						track = bow
					}
				}
				desc = mpo_nomad_events.1120.c.success
				send_interface_toast = {
					type = event_toast_effect_good
					title = mpo_nomad_events.1120.c.success
					left_icon = root
					
					if = {
						limit = {
							has_dlc_feature = tours_and_tournaments
						}
						if = {
							limit = {
								NOT = {
									has_trait = tourney_participant
								}
							}
							add_trait = tourney_participant
						}
						add_trait_xp = {
							trait = tourney_participant
							track = bow
							value = 10
						}
					}
					add_gold = minor_gold_value
				}
			}
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = -2.5
					min = -49
				}
				desc = mpo_nomad_events.1120.c.failure
				send_interface_toast = {
					type = event_toast_effect_bad
					title = mpo_nomad_events.1120.c.failure
					left_icon = root
					domicile = {
						change_herd = minor_herd_loss
					}
				}
			}
		}
		stress_impact = {
			patient = minor_stress_impact_gain
		}
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_rationality = -0.5
				ai_energy = 0.5
			}
			modifier = {
				factor = 0
				has_trait = patient
			}
		}
	}

	#So what? A few sick animals die. The wolves deserve this
	option = {
		name = mpo_nomad_events.1120.d
		flavor = mpo_nomad_events.1120.d.flavor
		
		add_piety = medium_piety_gain
		domicile = {
			change_herd = minor_herd_loss
		}
		stress_impact = {
			vengeful = medium_stress_impact_gain
			wrathful = medium_stress_impact_gain
			greedy = medium_stress_impact_gain
		}
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_greed = -1
				ai_vengefulness = -1
			}
			modifier = {
				factor = 0
				OR = {
					has_trait = greedy
					has_trait = vengeful
					has_trait = wrathful
				}
			}
		}
	}
}
